无法从硒导入webdriverwait

时间:2020-10-14 00:33:23

标签: python selenium webdriver

我是一名新程序员,最近尝试使用selenium发送WhatsApp消息,但始终显示无法从'selenium.webdrivr.support.ui'导入名称'webdriverwait'

   from selenium import webdriver
   from selenium.webdriver.support.ui import WebdriverWait
   from selenium.webdriver.support import Select
   from selenium.webdriver.common.keys import keys
   from selenium.webdriver.common.by import By
   from selenium.webdriver.chrome.options import Options
   import time

并显示以下Importerror

   ImportError                               Traceback (most recent call last)
   <ipython-input-1-34e812ae7ecd> in <module>
         1 from selenium import webdriver
   ----> 2 from selenium.webdriver.support.ui import WebdriverWait
         3 from selenium.webdriver.support import Select
         4 from selenium.webdriver.common.keys import keys
         5 from selenium.webdriver.common.by import By

    mportError: cannot import name 'WebdriverWait' from 'selenium.webdriver.support.ui' 
   (C:\Users\siddh\anaconda3\lib\site-packages\selenium\webdriver\support\ui.py)

2 个答案:

答案 0 :(得分:1)

正如ewong所说,您输入的是错误的内容。 WebDriverWait是您想要的。像所有其他编程语言一样,Python区分大小写。

替换:

from selenium.webdriver.support.ui import WebdriverWait

使用:

from selenium.webdriver.support.ui import WebDriverWait

答案 1 :(得分:0)

这些对我有用。我和@Unsigned_Arduino之间的唯一区别是,我为某些alias名称使用了class

进口

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as DriverWait
from selenium.webdriver.support import expected_conditions as DriverConditions