linux环境搭建webdriver+firefox+testn

2019-05-21  本文已影响0人  阡陌晗雪

  最近在centos7系统上搭建webdriver+firefox+testng环境,从eclipse项目迁移到IDEA中进行运行,环境迁移及配置出现各种问题。关于项目导出导入这里不做深入讲解。
环境说明:
centos7图形化桌面系统系统自带浏览器为firefox31.0版本
webdriver当前版本3.141.59
testng当前版本为6.14.3
出现问题:
1、已加载testng jar包,代码识别失败
  安装IDEA后,导入Module(具体为什么使用module,google一下),通过maven reimport项目依赖的testng、selenium包;导包后,发现项目中还是爆红,显示“unused import statement”


  依赖中是有testng的jar包,但是代码中还是爆红,这个很尴尬

  但是selenium导入的jar包就不会有这个问题,通过对比(如图),testng依赖jar中多scope属性。
  官方解释来啦!Dependency scope is used to limit the transitivity of a dependency, and also to affect the classpath used for various build tasks。意思就是依赖范围是用于限制依赖传递性,同时影响各种构建任务的classpath;关于scope详细解释及使用见http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
解决方式:将<scope>test</scope>删除或者将test修改为compile,问题完美解决。
2、环境配置完成后,确认自动化脚本中使用的是FireFoxDriver驱动对象,启动脚本,结果报:selenium Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:24469
  基本信息就是连接识别,浏览器是启动了,但是没有接下来的操作;分析结果为浏览器版本与webdriver版本不匹配导致。firefox的版本太低,只能升级firefox版本。
查看当前系统安装版本:
rpm -qa|grep firefox

卸载低版本:进入/usr/lib64目录,删除firefox目录
查看当前软件仓库firefox版本:
机器上已经安装了firefox60.6.1版本

[test@localhost ~]$ yum info firefox 
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * epel: mirror.sfo12.us.leaseweb.net
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
已安装的软件包
名称    :firefox
架构    :x86_64
版本    :60.6.1
发布    :1.el7.centos
大小    :207 M
源    :installed
来自源:updates
简介    : Mozilla Firefox Web browser
网址    :https://www.mozilla.org/firefox/
协议    : MPLv1.1 or GPLv2+ or LGPLv2+
描述    : Mozilla Firefox is an open-source web browser, designed for standards
         : compliance, performance and portability.

可安装的软件包
名称    :firefox
架构    :i686
版本    :60.6.1
发布    :1.el7.centos
大小    :93 M
源    :updates/7/x86_64
简介    : Mozilla Firefox Web browser
网址    :https://www.mozilla.org/firefox/
协议    : MPLv1.1 or GPLv2+ or LGPLv2+
描述    : Mozilla Firefox is an open-source web browser, designed for standards
         : compliance, performance and portability.

[test@localhost ~]$

使用yum安装新版本firefox:

sudo yum install firefox-60.6.1-1.el7.centos

软件包名称:名称-版本-发布

以上firefox信息中列出两个版本,第一个版本是已经安装的,也就是升级到的版本

3、firefox版本升级后,运行firefox,并确认版本号是否与安装的一致



浏览器升级完成了,重新跑下脚本,成功了,但是出现了一些红色的警告



暂时没看懂是什么意思,求大神指导

转载请注明出处

上一篇 下一篇

猜你喜欢

热点阅读