树莓派安装Firefox+Selenium+geckodriver
相关参考博客
【Selenium】Raspbian+Selenium+Firefox
firefox、geckodriver.exe、selenium-server-standlone版本对应及下载地址
树莓派如何安装火狐浏览器和geckodriver
geckodriver下载
前提:
最近需要在树莓派通过Java调用driver然后打开浏览器展示某些测试页面。
一开始通过Chromedriver结合Selenium调用Chrome,本地windows测试一切正常,部署至树莓派就会出现各种各样的问题,主要是driver与chrome和Selenium版本兼容问题导致不成功。
后来转向通过Selenium调用geckodriver控制firefox,成功展示相关页面。
1.首先树莓派安装Firefox
sudo apt-get install firefox-esr -y
通过以上命令进行firefox安装,安装成功后,可通过 whereis firefox 查看火狐浏览器安装路径.通常情况下在 /usr/bin/firefox 目录下。
查看火狐浏览器版本:
firefox -version
我的树莓派安装的版本为52,例如: Mozilla Firefox .*.*
另:也可通过ftp mozilla下载对应版本进行安装。
2.选择合适的geckodriver
可通过mozilla/geckodriver下载相关版本的 geckodriver 。
本地树莓派火狐浏览器版本为52,所以 geckodriver下载 v0.15.0 版本即可geckodriver-v0.15.0-arm7hf.tar.gz。
将下载后的包通过解压缩命令解压:
tar -zxvf geckodriver-v0.15.0-arm7hf.tar.gz
将解压后的文件 geckodriver 复制至 /usr/bin/ 目录下,并添加执行权限(+x)。
3.选择相应版本的Selenium
选择3.3.1版本的Selenium: selenium-server-standlone-3.3..jar .下载地址:http://selenium-release.storage.googleapis.com/index.html
一开始选择的是 selenium-java-3.3..jar ,调用过程异常,发现依赖进来的相关包的版本却是3.14.版本的,例如:selenium-firefox-3.14..jar ,修改为 selenium-server-standlone-3.3..jar 后正常。
4.测试
System.setProperty("webdriver.gecko.driver","/usr/bin/geckodriver");
FirefoxOptions firefoxOptions = new FirefoxOptions();
List<String> firefoxOp = new ArrayList<String>(10);
.....
firefoxOptions.addArguments(firefoxOp);
WebDriver firefoxDriver = new FirefoxDriver(firefoxOptions);
firefoxDriver.manage().window().maximize();
firefoxDriver.get("https://www.baidu.com");
运行代码,树莓派上能够正常打开火狐浏览器并转向相关测试页。
5.总结
- Firefox、selenium、geckodriver最难的是版本兼容,否则各种问题。
- Firefox、geckodriver、selenium-server-standlone版本对应如下:
selenium-server-standlone-3.3.1.jar http://selenium-release.storage.googleapis.com/index.html
geckodriver V.15.0 https://github.com/mozilla/geckodriver/releases
firefox 52.*.* http://ftp.mozilla.org/pub/firefox/releases/
6.注
在使用如下代码全屏浏览器时,会提示异常:firefoxDriver.manage().window().fullscreen();
在 geckodriver 是 0.15.0 版本会报错,提示: org.openqa.selenium.UnsupportedCommandException: unknown command: session/b368564bbe1863857d7ce10cc5f38e38/window/fullscreen.
此处是一个issue,该命令需要 0.17 版本以上,见原文Selenium 3 : Virtual - driver.manage().window().fullscreen() throwing org.openqa.selenium.UnsupportedCommandException.
This command is only supported in GeckoDriver since 0.17. Please try with latest GeckoDriver and, if it still doesn't work, provide a concise reproducible test case so that we could act on this issue.
树莓派安装Firefox+Selenium+geckodriver的更多相关文章
- 树莓派.安装Firefox浏览器
sudo apt-get install firefox-esr 要做全屏效果的话, 可以加装插件FF Fullscreen 插件地址: https://addons.mozilla.org/en-U ...
- 在Centos7上安装Python+Selenium+Firefox+Geckodriver
1.事先准备好Centos7的系统 Centos系统是CentOS Linux release 7.4.1708 (Core) 查看Centos内核版本命令cat /etc/centos-releas ...
- 在Centos7下安装Python+Selenium+Firefox学习环境
Selenium 一自动化测试工具.它支持 Chrome,Safari,Firefox 等主流界面式浏览器,如果你在这些浏览器里面安装一个 Selenium 的插件,那么便可以方便地实现Web界面的测 ...
- 在Centos7下docker配置自动化环境镜像(python3.7+selenium 3.11+firefox 62+geckodriver 0.21)
最近在学习Docker,准备做自动化测试代码集成的功能.如下文章的前提是已经安装好linux系统,且成功安装好Docker. 接下来我会按步骤一步一步的对自动化需要的一些环境进行安装,如果没有特别说明 ...
- 5--Selenium环境准备--firefox与geckodriver
selenium2时打开firefox浏览器是不需要安装firefoxdriver的,但是selenium3不支持向前支持火狐浏览器了,40以后版本的火狐,运行会出现问题. 1.下载geckodriv ...
- 自动化测试_Mac安装python+selenium
1.下载安装(参照下文) https://blog.csdn.net/kacylining/article/details/60587484 https://www.zhihu.com/questio ...
- chromedriver与chrome版本对应表,firefox、geckodriver
一. chromedriver与chrome对应表(记得就会更新): chromedriver版本 支持的Chrome版本 v2.36 v64-66 v2.35 v62-64 v2.34 v61-6 ...
- Firefox 与 geckodriver 版本兼容问题
打开 python shell,执行以下脚本: from selenium import webdriverdriver = webdriver.Firefox()driver.maximize_wi ...
- Ubuntu全新安装firefox最新版本
Ubuntu默认安装firefox,但是自带的软件仓库是不会随firefox更新的,我在使用中老是提示flash插件需要激活,提示中可选的解决方式有三种 1.更新flash插件,但是跳转到adobe的 ...
随机推荐
- 【零基础】Selenium:Webdriver图文入门教程java篇(附相关包下载)
一.selenium2.0简述 与一般的浏览器测试框架(爬虫框架)不同,Selenium2.0实际上由两个部分组成Selenium+webdriver,Selenium负责用户指令的解释(code), ...
- Netfilter 之 连接跟踪相关数据结构
Netfilter通过连接跟踪来记录和跟踪连接的状态,为状态防火墙和NAT提供基础支持: 钩子点与钩子函数 下图为钩子点和钩子函数的关系图(点击图片查看原图),其中ipv4_conntrack_def ...
- C++ STL——输入输出流
[TOC] 注:原创不易,转载请务必注明原作者和出处,感谢支持! 注:内容来自某培训课程,不一定完全正确! 一 缓冲区 (1)标准输入:从键盘输入数据到程序(input) (2)标准输出:程序数据输出 ...
- css 添加一个图标始终保持在pc端的右下角
<div class="dialog_maxdiv" style="display:block;"> <div id="center ...
- LC 638. Shopping Offers
In LeetCode Store, there are some kinds of items to sell. Each item has a price. However, there are ...
- Selenium 2自动化测试实战33(带unittest的脚本分析)
带unittest的脚本分析 #test.py #coding:utf-8 from selenium import webdriver from selenium.webdriver.common. ...
- [Http] Difference between POST and GET?
What is the difference between POST and GET HTTP requests? GET and POST are two different types of H ...
- centos7 忘记mysql root登录密码
1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的状态下,其他的用户也可以任意地登录和 ...
- HTML5元素周期表
HTML5元素周期表 根元素 1. html 文档根元素 元数据和脚本 1. head HTML文档中的第一个元素.包含文档元数据 2. title 文档标题 3. meta 文档的元数据. meta ...
- javaweb期末项目-stage1-part2-UML设计
UML设计.rar-下载 说明:解压密码为袁老师全名拼音(小写) 相关链接: 项目结构:https://www.cnblogs.com/formyfish/p/10828672.html 需求分析:h ...