测试总结-robotframework之UI自动化

环境配置

使用selenium+robotframework做UI自动化的第一个比较难搞的问题就是环境搭建,驱动+浏览器的版本匹配很重要,做自动化这么长时间每次都是硬伤,所幸就总结了一整套的环境配置,具体如下。

firefox+webdriver

在刚开始执行程序时出现错误,错误如下:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:5-3208198ce6fd}":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}","e":true,"v":"42.0","st":1448615838809,"mt":1446163994000}},"winreg-app-global":{"[email protected]":{"d":"C:\\Program Files (x86)\\Adobe\\Acrobat 10.0\\Acrobat\\Browser\\WCFirefoxExtn","e":false,"v":"1.2","st":1448675386446,"mt":1443109322000}}}1449741573914    addons.xpi    DEBUG    No changes found1449741573927    addons.xpi    DEBUG    Registering manifest for C:\Users\JC\AppData\Local\Temp\anonymous334187816099857851webdriver-profile\extensions\[email protected]    addons.xpi    DEBUG    Loading bootstrap scope from C:\Users\JC\AppData\Local\Temp\anonymous334187816099857851webdriver-profile\extensions\[email protected]    addons.xpi    DEBUG    Calling bootstrap method startup on [email protected] version 0.131449741574009    addons.xpi    DEBUG    Registering manifest for C:\Users\JC\AppData\Local\Temp\anonymous334187816099857851webdriver-profile\extensions\[email protected]    addons.xpi    DEBUG    Loading bootstrap scope from C:\Users\JC\AppData\Local\Temp\anonymous334187816099857851webdriver-profile\extensions\[email protected]    addons.xpi    DEBUG    Calling bootstrap method startup on [email protected] version 1.1.51449741574065    addons.manager    DEBUG    Registering shutdown blocker for XPIProvider1449741574066    addons.manager    DEBUG    Provider finished startup: XPIProvider1449741574066    addons.manager    DEBUG    Starting provider: LightweightThemeManager1449741574066    addons.manager    DEBUG    Registering shutdown blocker for LightweightThemeManager1449741574067    addons.manager    DEBUG    Provider finished startup: LightweightThemeManager1449741574067    addons.manager    DEBUG    Starting provider: GMPProvider1449741574080    addons.manager    DEBUG    Registering shutdown blocker for GMPProvider1449741574080    addons.manager    DEBUG    Provider finished startup: GMPProvider1449741574080    addons.manager    DEBUG    Starting provider: PluginProvider1449741574080    addons.manager    DEBUG    Registering shutdown blocker for PluginProvider1449741574081    addons.manager    DEBUG    Provider finished startup: PluginProvider1449741574081    addons.manager    DEBUG    Completed startup sequence1449741574278    addons.xpi-utils    DEBUG    Starting async load of XPI database C:\Users\JC\AppData\Local\Temp\anonymous334187816099857851webdriver-profile\extensions.jsonJavaScript warning: file:///C:/Users/JC/AppData/Local/Temp/anonymous334187816099857851webdriver-profile/extensions/[email protected]/components/ceTracking.js, line 129: JavaScript 1.7's let blocks are deprecated*** Blocklist::_loadBlocklistFromFile: blocklist is disabledJavaScript warning: file:///C:/Users/JC/AppData/Local/Temp/anonymous334187816099857851webdriver-profile/extensions/[email protected]/components/ceTracking-old.js, line 89: JavaScript 1.7's let blocks are deprecated1449741574870    addons.xpi-utils    DEBUG    Async JSON file read took 0 MS1449741574870    addons.xpi-utils    DEBUG    Finished async read of XPI database, parsing...1449741574873    addons.xpi-utils    DEBUG    Successfully read XPI database1449741575086    addons.manager    DEBUG    Starting provider: PreviousExperimentProvider1449741575086    addons.manager    DEBUG    Registering shutdown blocker for PreviousExperimentProvider1449741575087    addons.manager    DEBUG    Provider finished startup: PreviousExperimentProviderJavaScript error: http://offlintab.firefoxchina.cn/static/preload.html, line 127: ReferenceError: mozIndexedDB is not definedJavaScript warning: resource://addoninstaller/log4moz.js, line 494: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create1449741578000    addons.manager    DEBUG    Starting provider: 1449741578000    addons.manager    DEBUG    Registering shutdown blocker for 1449741578001    addons.manager    DEBUG    Provider finished startup:     at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:114)    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:193)    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:186)    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:182)    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:95)    at com.jc.test1.Demo1.main(Demo1.java:14)

我上网搜索了一下相关信息,发现是Firefox和webdriver的版本不匹配。

[Selenium]-->[FireFox]

2.25.0 -> 18

2.30.0 -> 19

2.31.0 -> 20

2.42.2 -> 29

2.44.0 -> 33 (不支持31,2014/12/1)

若selenium的版本和firefox不兼容,需要升级selenium的jar包,或者是升级firefox。


selenium之使用chrome浏览器测试(附chromedriver与chrome的对应关系表)

使用WebDriver在Chrome浏览器上进行测试时,需要从http://chromedriver.storage.googleapis.com/index.html网址中下载与本机chrome浏览器对应的驱动程序,驱动程序名为chromedriver;

chromedriver的版本需要和本机的chrome浏览器对应,才能正常使用;

第一步:下载对应版本的chromedriver驱动文件,具体版本请对照文章底部的对应关系表:

如本机的chrome浏览器版本为:版本 61.0.3163.100(正式版本) (64 位),对应的chromedriver版本为2.33.


测试总结-robotframework之UI自动化_第1张图片

第二步:下载后把文件解压,然后放到本机chrome浏览器文件路径里,如:

C:\Program Files (x86)\Google\Chrome\Application

测试总结-robotframework之UI自动化_第2张图片


第三步:操作完后,就可以使用以下代码直接调起浏览器了:

driver = new ChromeDriver();

测试总结-robotframework之UI自动化_第3张图片

附chromedriver与chrome的对应关系表:

chromedriver版本支持的Chrome版本

v2.33v60-62

v2.32v59-61

v2.31v58-60

v2.30v58-60

v2.29v56-58

v2.28v55-57

v2.27v54-56

v2.26v53-55

v2.25v53-55

v2.24v52-54

v2.23v51-53

v2.22v49-52

v2.21v46-50

v2.20v43-48

v2.19v43-47

v2.18v43-46

v2.17v42-43

v2.13v42-45

v2.15v40-43

v2.14v39-42

v2.13v38-41

v2.12v36-40

v2.11v36-40

v2.10v33-36

v2.9v31-34

v2.8v30-33

v2.7v30-33

v2.6v29-32

v2.5v29-32

v2.4v29-32

同版本的chromedriver下载

http://chromedriver.storage.googleapis.com/index.html

http://npm.taobao.org/mirrors/chromedriver/

配置成功的chromedriver+chrome版本

配了两天的驱动和浏览器,也只配成功了chrome的,内心是崩溃的

Chrome版本的


你可能感兴趣的:(测试总结-robotframework之UI自动化)