如何更改选择器,使网站显示登录,而不是使用selenium python和chromedriver注册?

2024-10-01 09:24:43 发布

您现在位置:Python中文网/ 问答频道 /正文

enter image description here 登记 登录 我用python编写的代码

driver.find_element_by_xpath("//div[@id='sectionContainer']//div[@id='login_section_btn']")
#driver.execute_script("arguments[0].setAttribute('class','active_section_btn')", element)

我收到的错误消息是:

Unable to locate element: {"method":"xpath","selector":"//div[@id='sectionContainer']//div[@id='login_section_btn']"} (


Tags: 代码imagedividheredriverloginsection
1条回答
网友
1楼 · 发布于 2024-10-01 09:24:43
driver = webdriver.Chrome()
driver.get("https://secura.e-sim.org/")
WebDriverWait(driver, 10).until(
    EC.presence_of_element_located(
        (By.XPATH, "// div[@id='sectionContainer']//div[@id='login_section_btn']"))
).click()

您应该使用显式wait for waiting,直到元素正确加载。第二个不可交互的错误元素可能是因为按钮被禁用或其他原因,除非我们能够访问网站或进行屏幕截图,否则很难判断

相关问题 更多 >