lec2
In [4]:
# code for my VM:
# from selenium import webdriver
# from selenium.webdriver.chrome.options import Options
# from selenium.common.exceptions import NoSuchElementException
# options = Options()
# options.headless = True
# b = webdriver.Chrome(options=options, executable_path=”chromium.chromedriver”)
# for my laptop:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import NoSuchElementException
options = Options()
#options.headless = True
b = webdriver.Chrome(options=options)
In [2]:
import time
print(“A”)
time.sleep(3)
print(“B”)
A
B
In [3]:
# STEP 1: get the HTML corresponding to the hidden table
url = “https://tyler.caraza-harter.com/cs320/tricky/page1.html”
b.get(url)
def wait_for_element(element_id):
max_seconds = 10
for i in range(max_seconds*10):
time.sleep(0.1)
try:
elem = b.find_element_by_id(element_id)
break
except NoSuchElementException:
print(“not ready”)
wait_for_element(“coords”)
print(b.page_source[:200])
not ready
not ready
not ready
not ready
not ready
not ready
not ready
not ready