PyCharm解决报错module selenium.webdriver.chrome has no attribute XXX

PyCharm在运行以下代码时一直报错
module ‘selenium.webdriver.chrome’ has no attribute ‘implicitly_wait’

from selenium import webdriver
driver = webdriver.Chrome()
def login(user,userpassword):
    driver.get("http://localhost:8080/servletApply_war_exploded/test.html")
    driver.implicitly_wait(5)

    driver.find_element_by_id('user').send_keys(user)
    driver.find_element_by_id('userpassword').send_keys(userpassword)
    driver.find_element_by_name("submit").click

    handle = driver.current_url

    if handle == 'http://localhost:8080/servletApply_war_exploded/yinglang/index.html':
        print('账号:' + user + '\n密码:' + userpassword + '\n登录成功\n')
    else:
        print('账号:' + user + '\n密码:' + userpassword + '\n登录失败\n')


login('tom','123')

百度尝试了很多方法,包括修改脚本名称、删除重装selenium、卸载重装PyCharm都无法解决

之后删除了原代码,写了几行简单的运行

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.baidu.com/")
driver.quit()

运行成功,没有报错
然后删掉了这几行代码换成之前一直报错的代码,就不报错了,运行成功,原因未知

猜你喜欢

转载自blog.csdn.net/sunshine543123/article/details/107003603