WebDriverWait.__init__() 缺少 1 个必需的位置参数:“超时”
我在等待命令时收到此错误。
element = WebDriverWait('self.driver, 10').until(EC.presence_of_element_located((By.ID, 'user-name-input')))
TypeError: WebDriverWait.__init__() missing 1 required positional argument: 'timeout'
这些是我的命令,我在这里错过了什么?
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import selenium
import selenium_elements
import webbrowser
from selenium import webdriver
from webbrowser import Chrome
driver = webdriver.Chrome()
browser = Chrome()
webbrowser.open('https://...')
element = WebDriverWait('self.driver,
10').until(EC.presence_of_element_located((By.ID, 'user-name-input')))
driver.find_element(By.ID, "user-name-input").clear()
driver.find_element(By.ID, "user-name-input").send_keys('UserName')
driver.find_element(By.ID, 'user-password-input').clear()
driver.find_element(By.ID, 'user-password-input').send_keys('Password')
driver.find_element(By.ID, 'login-submit-button').click()
driver.find_elemente(By.CLASS_NAME, 'logout-btn')
I am receiving this error on wait command.
element = WebDriverWait('self.driver, 10').until(EC.presence_of_element_located((By.ID, 'user-name-input')))
TypeError: WebDriverWait.__init__() missing 1 required positional argument: 'timeout'
these are my commands, What do I miss here?
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import selenium
import selenium_elements
import webbrowser
from selenium import webdriver
from webbrowser import Chrome
driver = webdriver.Chrome()
browser = Chrome()
webbrowser.open('https://...')
element = WebDriverWait('self.driver,
10').until(EC.presence_of_element_located((By.ID, 'user-name-input')))
driver.find_element(By.ID, "user-name-input").clear()
driver.find_element(By.ID, "user-name-input").send_keys('UserName')
driver.find_element(By.ID, 'user-password-input').clear()
driver.find_element(By.ID, 'user-password-input').send_keys('Password')
driver.find_element(By.ID, 'login-submit-button').click()
driver.find_elemente(By.CLASS_NAME, 'logout-btn')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
webdriverwait()
构造函数将WebDriver实例和超时以秒为单位。在您通过A字符串
时,您只需要:
有效地,您的代码行将是:
The
WebDriverWait()
constructor takes a WebDriver instance and timeout in seconds. Where as you have passed astring
You just need:
Effectively, your line of code will be: