after I log in to the website through selenium, I want to start automatically clicking some buttons on the web page. Through xpath positioning, I can"t find
code is as follows (account password is not important, you need to log in to enter the course, leaving it easy for everyone to help debug)
from selenium import webdriver
import time
-sharp chrome
opt = webdriver.ChromeOptions()
-sharp chromewindowslinux
-sharpopt.set_headless()
-sharp chrome
driver = webdriver.Chrome(options=opt)
driver.get("https://www.ulearning.cn/umooc/user/login.do")
-sharp
-sharpprint(driver.page_source)
-sharp
user = driver.find_element_by_xpath("//*[@id="loginName"]")
user.send_keys("20164045033")
-sharp
password = driver.find_element_by_xpath("//*[@id="password"]")
password.send_keys("dk154310")
-sharp
bt = driver.find_element_by_xpath("//*[@id="loginForm"]/input[3]").click()
print(driver.page_source)
-sharpprint(driver.get_cookies())
-sharp cookies = {
-sharp "domain": "www.ulearning.cn",
-sharp "httpOnly": False,
-sharp "name": "staticCookie",
-sharp "path": "/ulearning_web",
-sharp "secure": True,
-sharp "value": "1"
-sharp }
-sharp
-sharp
time.sleep(3)
-sharp
learn = driver.find_element_by_xpath("/html/body/div[2]/div[2]/div/div[1]/div[1]/div/div/div/section[1]/div[2]/div[1]/div[5]/input").click()
time.sleep(10)
test = driver.find_element_by_xpath("//*[@id="page559654"]/div/div/span").click()
is that the element of the last line can not be found, it feels like it is loaded with javascript subclass, but I will not, please take a look at it and give the solution, thank you!