??最近在centos7系統(tǒng)上搭建webdriver+firefox+testng環(huán)境谎碍,從eclipse項目遷移到IDEA中進行運行卤恳,環(huán)境遷移及配置出現(xiàn)各種問題累盗。關(guān)于項目導出導入這里不做深入講解。
環(huán)境說明:
centos7圖形化桌面系統(tǒng)系統(tǒng)自帶瀏覽器為firefox31.0版本
webdriver當前版本3.141.59
testng當前版本為6.14.3
出現(xiàn)問題:
1突琳、已加載testng jar包若债,代碼識別失敗
??安裝IDEA后,導入Module(具體為什么使用module拆融,google一下)蠢琳,通過maven reimport項目依賴的testng、selenium包镜豹;導包后傲须,發(fā)現(xiàn)項目中還是爆紅,顯示“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。意思就是依賴范圍是用于限制依賴傳遞性咬最,同時影響各種構(gòu)建任務的classpath翎嫡;關(guān)于scope詳細解釋及使用見http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
解決方式:將<scope>test</scope>刪除或者將test修改為compile欠动,問題完美解決永乌。
2、環(huán)境配置完成后具伍,確認自動化腳本中使用的是FireFoxDriver驅(qū)動對象翅雏,啟動腳本,結(jié)果報:selenium Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:24469
??基本信息就是連接識別人芽,瀏覽器是啟動了望几,但是沒有接下來的操作;分析結(jié)果為瀏覽器版本與webdriver版本不匹配導致萤厅。firefox的版本太低橄抹,只能升級firefox版本。
查看當前系統(tǒng)安裝版本:
rpm -qa|grep firefox
卸載低版本:進入/usr/lib64目錄惕味,刪除firefox目錄
查看當前軟件倉庫firefox版本:
機器上已經(jīng)安裝了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
架構(gòu) :x86_64
版本 :60.6.1
發(fā)布 :1.el7.centos
大小 :207 M
源 :installed
來自源:updates
簡介 : Mozilla Firefox Web browser
網(wǎng)址 :https://www.mozilla.org/firefox/
協(xié)議 : MPLv1.1 or GPLv2+ or LGPLv2+
描述 : Mozilla Firefox is an open-source web browser, designed for standards
: compliance, performance and portability.
可安裝的軟件包
名稱 :firefox
架構(gòu) :i686
版本 :60.6.1
發(fā)布 :1.el7.centos
大小 :93 M
源 :updates/7/x86_64
簡介 : Mozilla Firefox Web browser
網(wǎng)址 :https://www.mozilla.org/firefox/
協(xié)議 : 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
軟件包名稱:名稱-版本-發(fā)布
以上firefox信息中列出兩個版本楼誓,第一個版本是已經(jīng)安裝的,也就是升級到的版本
3名挥、firefox版本升級后疟羹,運行firefox,并確認版本號是否與安裝的一致
瀏覽器升級完成了禀倔,重新跑下腳本榄融,成功了,但是出現(xiàn)了一些紅色的警告
暫時沒看懂是什么意思救湖,求大神指導
轉(zhuǎn)載請注明出處