[selenium] mac M1 environment python selenium chromewebdriver environment construction

Mac Air M1 system

  1. According to the environment of Python3.7+
  2. Pycharm installation
  3. Install selenum through pip installation or through pycharm installation
  4. Install chromewebdriver Download address: http://chromedriver.storage.googleapis.com/index.html, download and install the same webdriver as the local chrome version, reference address: https://cloud.tencent.com/developer/article/1365269
  5. Write the test code:
#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2021/11/21 5:08 PM
# @Author  : baosenzhang
# @File    : Hello.py
# @Software: PyCharm

from selenium import webdriver
import time
if __name__ == '__main__':
    driver = webdriver.Chrome()
    driver.get('http://www.baidu.com')
    time.sleep(8)
    driver.close()

An error will be reported on the first run on the Mac system Service chromedriver unexpectedly exited. Status code was: -9. This prompt means that the chromedriver program is not trusted on the Mac system. You need to click "Open anyway" in Mac System Preferences - Security and Privacy - General. Refer to: https://jingyan.baidu.com/article/afd8f4de7a72b375e286e9f1.html Run the above code again to run
through

Guess you like

Origin blog.csdn.net/weixin_45329445/article/details/121456826