我正在使用 Python selenium 版本 3.0.1,其中似乎不是说
driver.implicitly_wait(10)
Run Code Online (Sandbox Code Playgroud)
我们现在必须说
driver.implicitly_wait(10, TimeUnit.SECONDS)
Run Code Online (Sandbox Code Playgroud)
这给了我错误......
NameError:名称“TimeUnit”未定义
所以我需要导入 TimeUnit,但是我从哪里(什么模块)导入它?
https://pypi.python.org/pypi/selenium上的文档链接将我带到 selenium 2 文档,在搜索框中输入 TimeUnit 会显示一个空白。因此,任何想要告诉我阅读文档的人都需要告诉我正确的文档在哪里。
我不知道是什么TimeUnit.SECONDS,但不管它是什么,implicitly_wait() 只需要一个论点!
>>> help(driver.implicitly_wait)
Help on method implicitly_wait in module selenium.webdriver.remote.webdriver:
implicitly_wait(time_to_wait) method of selenium.webdriver.firefox.webdriver.Web
Driver instance
Sets a sticky timeout to implicitly wait for an element to be found,
or a command to complete. This method only needs to be called one
time per session. To set the timeout for calls to
execute_async_script, see set_script_timeout.
:Args:
- time_to_wait: Amount of time to wait (in seconds)
:Usage:
driver.implicitly_wait(30)
Run Code Online (Sandbox Code Playgroud)
因此,如果您尝试发送任何 2 个参数,您应该得到
TypeError:implicitly_wait() 需要 2 个位置参数,但给出了 3 个
PS 另外不要忘记,在这种情况下,第一个位置参数是self指对象本身
| 归档时间: |
|
| 查看次数: |
9438 次 |
| 最近记录: |