Python 中selenium模块报错selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home


----------------------------------------------------------------------
Ran 1 test in 0.014s

FAILED (errors=1)

先检查浏览器版本

这里写图片描述

再去到 https://sites.google.com/a/chromium.org/chromedriver/home
下载对应的chromedriver版本

解压放到 python安装文件里面去就可以跑动了

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

from selenium import webdriver

import unittest

from selenium.webdriver.support.wait import WebDriverWait


class Test_web(unittest.TestCase):

    def setUp(self):
        self.timeout = 40
        self.brower = webdriver.Chrome()
        self.brower.set_page_load_timeout(self.timeout)
        self.wait = WebDriverWait(self.brower,self.timeout)

    def tearDown(self):
        pass

    def test_can_start(self):
        self.brower.get('http://10.7.152.104:8080/')
        self.assertIn('物业管理',self.brower.title)
        login_link = self.wait.until(
            EC.element_to_be_clickable((By.LINK_TEXT, '业主登录')))

        login_link.click()


if __name__ == '__main__':
    unittest.main(warnings='ignore')


还有个笨办法:
把chromedriver放到下面这个路径
C:\Program Files (x86)\Google\Chrome\Application

在代码里面的Chrome()中添加路径就Ok
Chrome(‘C:\Program Files (x86)\Google\Chrome\Application\chromedriver’)
但是这样很麻烦每次写路径

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值