问题:selenium mac chrome浏览器没有打开

    path = “/usr/local/bin/chromedriver” driver = webdriver.Chrome(path)

    安装ddt模块

    pip install ddt


    1. import unittest
    2. import time
    3. from selenium import webdriver
    4. path = "/usr/local/bin/chromedriver"
    5. #通过继承unittest.TestCase来实现用例
    6. class forTest(unittest.TestCase):
    7. #用例初始化
    8. def setUp(self):
    9. print('set up')
    10. #用例释放
    11. def tearDown(self):
    12. print("tearDown")
    13. #类的初始化
    14. @classmethod
    15. def setUpClass(cls) -> None:
    16. print('class')
    17. #类的释放
    18. @classmethod
    19. def tearDownClass(cls) -> None:
    20. print('tclass')
    21. #定义测试用例
    22. def test_1(self):
    23. driver = webdriver.Chrome(path)
    24. driver.get("http://www.baidu.com")
    25. driver.find_element_by_id('kw').send_keys('pandab')
    26. driver.find_element_by_id('su').click()
    27. time.sleep(5)
    28. if __name__== '__main__ ':
    29. unittest.main(verbosity=1)
    30. unittest.main()

    image.png