python2.7 + selenium3.4.3浏览器的选择
大家都知道,selenium2对火狐浏览器兼容性比较好,和谷歌和IE相比,好处是无需安装相应的driver.exe来支持启动浏览器,但是缺点是最高支持火狐47版本。
现在selenium3出来了,是不是支持高版本的火狐浏览器了呢,答案是肯定的而且火狐浏览器必须是48或者更高版本,还需要geckodriver来支持。把geckodriver放在path路径下即可。
代码如下:
#coding=utf-8
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.action_chains import ActionChains
browser = webdriver.Firefox()
browser.get("https://www.baidu.com")
个别电脑使用以上代码启动可能报以下错误
解决方法:指定浏览器的路径,具体要看自己浏览器的安装路径
#coding=utf-8
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
browser = webdriver.Firefox(firefox_binary=binary)
browser.get("https://www.baidu.com")
但是导入ActionChains鼠标操作类执行双击、移动鼠标到元素等事件都报错:
Message: POST /session/7e857f95-4522-4898-abce-384e4ec00ca2/actions did not match a known command
原因这是Mozilla/geckodriver的一个bug,由于geckodriver开发是2016年中旬的,所以只能这对firefox47或者更老的版本使用,如果你要使用selenuym3+firefox,请使用较老版本的firefox。经测试selenium3+Chrome58使用正常,及时现在geckodriver有更新版本,解决了以上的鼠标操作事件问题,还是出现了其他问题,如设置浏览器最大化等等。
python2.7 + selenium3.4.3浏览器的选择的更多相关文章
- Selenium3自动化问题一:selenium3在火狐浏览器执行driver.quit()报错2052解决方案
一:问题说明 最近用到selenium3在火狐浏览器中执行自动化脚本,每次执行到driver.quit()方法总是报错,报错日志如下: 二:解决方案 搜了一圈网上的资料,都说是火狐的问题,于是去到se ...
- selenium3 + python 操作浏览器基本方法
from selenium import webdriverimport time as t # driver = webdriver.Chrome()# driver.get("http: ...
- selenium3驱动IE浏览器设置
前言: 使用selenium3+IE11的方式进行自动化测试 准备工作: 1.ie的驱动:IEDriverServer.exe(对应系统位数) 2.已安装好python3.selenium所需的相关服 ...
- 纯javascript代码实现浏览器图片选择预览、旋转、批量上传
工作中遇到的业务场景,和同事一起研究了下,主要是为了兼容IE版本 其实就是一些琐碎的知识点在网上搜集下解决方式,然后集成了下,主要有以下点: 1. IE input type=file的图片预览要用I ...
- 系统中同时有 python2和 python3,怎么让 ipython 选择不同的版本启动?
已经安装的情况下: > which ipython /usr/local/bin/ipython > cat /usr/local/bin/ipython #!/usr/local/op ...
- selenium3加载浏览器
浏览器禁用更新: 因为selenium对浏览器的支持是有限制的.当浏览器更新到最新版本时,需要下载支持最新版本的插件.有时候selenium还没有更新到支持最新版本的插件,但本地已经更新到最新版本了. ...
- tomcat中浏览器重新选择下.就解决该问题了
- selenium3 + Python - 处理浏览器弹窗(转载)
作者:Real_Tino 转载链接:https://blog.csdn.net/real_tino/article/details/59068827 我们在浏览网页时经常会碰到各种花样的弹窗,在做UI ...
- 根据ie浏览器不同的类别选择不同的css
如果是IE浏览器则选择all-ie-only.css <!--[if IE]> <link rel="stylesheet" type="text/cs ...
随机推荐
- 抓包工具 - Fiddler(详细介绍)
Fiddler的详细介绍 一.Fiddler与其他抓包工具的区别 1.Firebug虽然可以抓包,但是对于分析http请求的详细信息,不够强大.模拟http请求的功能也不够,且firebug常常是需要 ...
- SICP-1.5-控制结构
测试 DOCSETS 在docstring中直接添加测试 def sum_naturals(n): """Return the sum of the first n na ...
- Android Studio开发环境配置(win7)
由于近期,google网站封锁,导致eclipse配置android环境时,无法在线更新API和配置ADT.个人尝试之后,发现很多地方配置因为版本不合适而配置不成功,(ps:当然你FQ,或者下载到对应 ...
- linux查询进程号,出现两个进程
[root@ADM01B ~]# ps -ef|grep iesmgr root 5929 5321 0 09:38 pts/7 00:00:00 grep iesmgr root 9798 1 0 ...
- Spring Boot 集成swagger实例
原文:https://github.com/x113773/testall/issues/5 1. 首先添加maven依赖``` <dependency> <groupId>i ...
- vue 基础-->进阶 教程(3):组件嵌套、组件之间的通信、路由机制
前面的nodejs教程并没有停止更新,因为node项目需要用vue来实现界面部分,所以先插入一个vue教程,以免不会的同学不能很好的完成项目. 本教程,将从零开始,教给大家vue的基础.高级操作.组件 ...
- [leetcode-442-Find All Duplicates in an Array]
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others ...
- 【LeetCode】87. Scramble String
题目: Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty subs ...
- ajax数据请求5(php格式)
ajax数据请求5(php格式): <!DOCTYPE html> <html> <head> <meta charset="UTF-8" ...
- PVM的安装和编译PVM程序
最近刚开始学习并发编程,学习到了PVM这一块.关于在linux系统中PVM的安装,真是要我的命,繁琐死了,最关键是我对linux也是刚开始学,还在继续学习<鸟哥的linux私房菜>一书.好 ...