网络看了很多的文章,大部分都是不完整, 还有很多误导性极强的教程 ,特别是chromedriver这东西.简直一堆坑.

一首先是安装python3.6.5

root@ubuntu:~# add-apt-repository ppa:jonathonf/python-3.6

root@ubuntu:~# apt-get update

root@ubuntu:~# apt-get install python3.6

root@ubuntu:~# python3.6

如果出现以下内容证明成功:

Python 3.6.5 (default, May  3 2018, 10:08:28)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

二:设置默认python3对应为python3.6

root@ubuntu:~# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1

root@ubuntu:~# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

root@ubuntu:~# update-alternatives --config python3

看到以下内容:

There are 2 choices for the alternative python3 (providing /usr/bin/python3).

Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.6   2         auto mode
 1            /usr/bin/python3.5   1         manual mode
 2            /usr/bin/python3.6   2         manual mode
Press <enter> to keep the current choice[*], or type selection number:

回车完毕

三:升级pip3

root@ubuntu:~# apt-get install python3-pip

root@ubuntu:~# pip3 install --upgrade pip

四:安装selenium

root@ubuntu:~# pip3 install selenium

五:安装chrome浏览器

下载谷歌浏览器的deb安装包

##  https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

$sudo apt install libappindicator1 libindicator7

$sudo dpkg -i google-chrome-stable_current_amd64.deb

$sudo apt -f install        ####修复依赖关系

六:安装chromedriver

    chromedriver版本对照表如下

ChromeDriver v2.41 (2018-07-07)----------Supports Chrome v67-69

ChromeDriver v2.40 (2018-06-07)----------Supports Chrome v66-68
ChromeDriver v2.39 (2018-05-30)----------Supports Chrome v66-68
ChromeDriver v2.38 (2018-04-17)----------Supports Chrome v65-67
ChromeDriver v2.37 (2018-03-16)----------Supports Chrome v64-66
ChromeDriver v2.36 (2018-03-02)----------Supports Chrome v63-65
ChromeDriver v2.35 (2018-01-10)----------Supports Chrome v62-64

比如要按照自己系统chrome浏览器版本下载对应chromedriver版本
将下载chromedriver放到/usr/bin/下
=== 代码需要指定chromedriver的路径,不是系统chrome浏览器的路径,这个要千万注意.如下:
chromedriver = "/usr/local/bin/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.get(url="https://www.qq.com")
测试以上代码,如果chrome浏览器能正常出来并打开qq那就是chromedriver已安装好.
原本路径可以直接写到系统的环境变量里的,只可惜,如果这样做,crontab去调用chrome的时候就是报错. === 如需要将脚本放到crontab里去执行需要原来的执行命令前加上 export DISPLAY=:0&& 如下
export DISPLAY=:0&&/usr/bin/python3 /apps/run_brower_text.py >> /apps/auto.log 2>&1
												

python3使用selenium3的坑的更多相关文章

  1. python3.6+selenium3.13 自动化测试项目实战一

    自己亲自写的第一个小项目,学了几天写出来的一个小模块,可能还不是很完美,但是还算可以了,初学者看看还是很有用的,代码注释不是很多,有问题可以加我QQ 281754043 一.项目介绍 目的: 测试某官 ...

  2. Python3.0+Selenium3进行Web自动化遇到的坑

    1.搭建环境时,已经把chromedriver的路径加入到PATH,但是还是报错说需要加入PATH.此时重新启动下Pycharm即可

  3. 总结一下连日来在MAC下被Python3设下的坑

    当时的情况:mac下自带python2, 1.安装pyhon3: 首次从官网下载了安装包安装,安装目录在/Library/Frameworks/Python.framework/Versions/3. ...

  4. 学以致用十一-----centos7.2+python3+YouCompleteMe走过的坑

    目的,安装YouCompleteMe 插件 参考的资料 https://blog.csdn.net/zs376957686/article/details/77833953 https://www.c ...

  5. selenium3 踩坑--move_to_element()报错

    问题:selenium3 使用move_to_element()报错,报错信息如下图所示: 网上没有找到合适的解决办法,回退到稳定的selenium2可以解决. pip install seleniu ...

  6. window下搭建Python3.7+selenium3.1.1+pycharm环境

    1.安装Python3.7 1.1  下载 Python并安装 Python3.5 (勾选上 Add Python3.7 to PATH) 点击 Install Now,安装完成后将python路径加 ...

  7. mac 关于默认python2下的pip,和python3下pip 的坑

    pip是常用的python包管理工具,类似于java的maven.用python的同学,都离不开pip. 1.在Python2.7的安装包中,easy_install.py是默认安装的,而pip需要手 ...

  8. python2和python3中split的坑

    执行同样的split,python2和python3截取的行数内容却不一样 我想要截取Dalvik Heap行,使用split('\n')的方法 import os cpu='adb shell du ...

  9. python3.x运行的坑:AttributeError: 'str' object has no attribute 'decode'

    1.Python3.x和Python2.X版本有一些区别,我遇到了两个问题如下: a.第一个报:mysqlclient 1.3版本不对: 解决办法:注释掉这行即可: b.第二个报:字符集的问题: 报错 ...

随机推荐

  1. 小松之LINUX 驱动学习笔记(二)

    这两天一直在看字符驱动那块,后来从网上找啦几个例子,自己编译啦下,安装啥的都挺正常,就是用测试程序测试的时候总出问题,现在找到一个能测试的代码,自己先看看和原来的那个代码有啥不同,后面会继续更新,说下 ...

  2. android window类

    Android的Window类(一) Android的GUI层并不复杂.它的复杂度类似于WGUI这类基于布局和对话框的GUI,与MFC.QT等大型框架没有可比性,甚至飞漫魏永明的MiniGUI都比它复 ...

  3. springboot 不使用前端模板直接跳转页面

    1.创建springboot项目 2.在resource 下创建pages文件夹,存放所有页面 3.编写后台代码 4.访问http://localhost:8080/index,即可跳转到页面

  4. 给 string 添加一个 GetInputStream 扩展方法

    有时候,我们须要读取一些数据,而无论这数据来源于磁盘上的数据文件,还是来源于网络上的数据.于是.就有了以下的 StringExtensions.cs: using System; using Syst ...

  5. Ruby中使用patch HTTP方法

    Ruby中使用patch HTTP方法 如果使用patch,在后台可以看到只更新了改动的部分: Started PATCH "/ads/5/update" for ::1 at 2 ...

  6. Android 开发最佳实践

    原文地址:https://github.com/futurice/android-best-practices/blob/master/translations/Chinese/README.cn.m ...

  7. 项目部署在windows下的tomcat里

    打包放在webapps 目录下,web的改成ROOT ok!!!

  8. Gradle之依赖管理

    Gradle之依赖管理 泡在网上的日子 / 文 发表于2015-01-29 16:12 第8824次阅读 Gradle,Android Studio 2 编辑推荐:稀土掘金,这是一个针对技术开发者的一 ...

  9. 18. 4Sum[M]四数之和

    题目 Given an array nums of n integers and an integer target, are there elements a, b, c and d in nums ...

  10. extjs 与html相结合 自定义

    http://skirtlesden.com/articles/html-and-extjs-components