我有下面的代码。
from selenium import webdriver
import time
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
driver = webdriver.Chrome() #
driver.implicitly_wait(10) #https://blog.csdn.net/u010895119/article/details/77005886
driver.get('http://www.aim.env.uea.ac.uk/aim/model4/model4d.php') #
button = driver.find_element_by_id('add_organic')#
button.click()#
input = driver.find_element_by_id("selection_box_id")#
input.click()
driver.find_element_by_xpath('//*[@id="selection_box_id"]/option[3]').click() #
driver.find_element_by_xpath('//*[@id="selection_box_div"]/p/input').click()#
input = driver.find_element_by_id("selection_box_id")#
input.click()
driver.find_element_by_xpath('//*[@id="selection_box_id"]/option[7]').click()#
driver.find_element_by_xpath('//*[@id="selection_box_div"]/p/input').click()#
driver.find_element_by_xpath('//*[@id="BacktoCalculation_id"]').click() #
#driver.execute_script("window.history.go(-1)") #https://stackoverflow.com/questions/27626783/python-selenium-browser-driver-back
wait = WebDriverWait(driver, 10) #
element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="mainForm"]/div[2]/table/tbody/|tr/td[3]/input')))#
element.click()
我总是遇到超时错误:
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
但是当我尝试直接找到元素时,它确实有效。但我需要在这里明确等待以确保安全。任何人都可以帮助找出上面代码中的问题吗?非常感谢!
element = driver.find_element_by_xpath('//*[@id="mainForm"]/div[2]/table/tbody/tr/td[3]/input')
慕桂英3389331
相关分类