【发布时间】:2022-01-04 22:48:57
【问题描述】:
我目前的代码是:
driver.get("http://w2.leisurelink.lcsd.gov.hk/index/index.jsp")
window1 = driver.window_handles[0]
facility_basic_version = driver.find_element_by_xpath("/html/body/div[1]/div/div/div[3]/div[2]/div/div[3]/div/div[3]/div[1]/table/tbody/tr/td/div")
facility_basic_version.click()
# deselect selected captcha
window2 = driver.window_handles[1]
driver.switch_to.window(window2)
WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH, '//div[@class="kbkey button red_selected sel"]'))).click()
#Solve Captcha here
#
#
#
# Click continue at specific time
while len(driver.find_elements_by_xpath('//div[@class="kbkey button red_selected sel"]')) < 4:
print('captcha not done')
pyautogui.moveTo(634, 586, 0.5, pyautogui.easeInQuad)
time.sleep(0.3)
pyautogui.mouseDown()
pyautogui.mouseUp()
print('captcha done')
time.sleep(100)
我有一个部分可以解决验证码,但由于我还没有实现该部分,出于测试目的,我仍在手动解决验证码。
问题:解决验证码后,我想点击继续按钮。但是,如果尝试查找元素,然后单击按钮,我会遇到错误(站点知道我正在使用自动化)。我尝试启动 chromedriver,执行机器人将手动执行的所有步骤并手动单击继续按钮,该站点将允许我继续到下一页。因此,我尝试使用 pyautogui 来模拟鼠标移动,但网站仍然给我错误。
【问题讨论】:
标签: html selenium selenium-webdriver webdriver