Mac下python+selenium【1】环境搭建
写在最前⾯:
搞⾃动化测试呢有很⼤概率会⽤到selenium,其实⽤什么语⾔都可以,这次先从python讲起。其实在win下我已经⽤了很久了,今天讲讲
Mac下的安装。
⾸先是环境搭建,本⽂基于macOS Mojave操作系统,我⽤的是python3.6+pycharm,这个就不介绍了,然后我们来安装selenium。
pip3 install selenium
Collecting selenium
Downloading /packages/80/d6/4294f0b4bce4de0abf13e17190289f9d0613b0a44e5dd6a7f5ca98459853/selenium-3.141.0-py2.py3    100% |████████████████████████████████| 911kB 11kB/s
Requirement already satisfied: urllib3 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from selenium) (1.23)
Installing collected packages: selenium
Successfully installed selenium-3.141.0
我的chrome版本是
我下的chromedriver版本是
如何搭建第三方网站我按照win的习惯放在项⽬⽬录下了。
接下来简单测试⼀下:
from selenium import webdriver
import selenium
if __name__ == "__main__":
driver = webdriver.Chrome()
<('www.baidu/')
不出意外的报错了
Traceback (most recent call last):
File "/Users/Arithmetic/PycharmProjects/AutoTest/FirstTest.py", line 5, in <module>
driver = webdriver.Chrome()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
sudo vim .bash_profile
输⼊密码
export PATH=$PATH:ChromeDriver
usb device over current
esc
:
wq!
source .bash_profile
python安装教程mac然后⼜报了另⼀个错
Traceback (most recent call last):
File "/Users/Arithmetic/PycharmProjects/AutoTest/FirstTest.py", line 5, in <module>
linux系统源代码下载
driver = webdriver.Chrome()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
java游戏开发教程全套
raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: 'chromedriver'三义观影
尝试将chromedriver放⼊
/usr/local/bin
成功!
其实我试过了,不添加路径也可以。。。
记得输⼊完整的⽹址,不然貌似打不开。
今天只讲环境搭建。
今天双⼗⼀实际上只剁⼿了⼀件nike的⽻绒服,原价1199,实付401,真**便宜,晚安各位~

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。