51Testing软件测试论坛
标题: selenium3 beta初体验 [打印本页]
作者: 测试积点老人 时间: 2018-12-18 15:28
标题: selenium3 beta初体验
本帖最后由 测试积点老人 于 2018-12-18 15:30 编辑
从selenium 1.0 至今,差不多有十多年的历史。
那么selenium3.0 为我们带来了什么?
看一下changelog怎么写的:
- v3.0.0-beta2
- ============
- * maven packaging fixes
- * Update GeckoDriver --port argument in all bindings
- * System property webdriver.firefox.marionette now forces the server in marionette or legacy firefox driver mode, ignoring any related Desired Capability
- * Grid fix NPE's on registration when -browser not specified
- v3.0.0-beta1
- ============
- IMPORTANT CHANGES
- * Minimum java version is now 8+
- * The original RC APIs are only available via the leg-rc package.
- * To run exported IDE tests, ensure that the leg-rc package is on the
- classpath.
- * Support for Firefox is via Mozilla's geckodriver. You may download
- this from https://github.com/mozilla/geckodriver/releases
- * Support for Safari is provided on macOS (Sierra or later) via
- Apple's own safaridriver.
- * Support for Edge is provided by MS:
- https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
- * Official support for IE requires version 9 or above. Earlier
- versions may work, but are no longer supported as MS has
- end-of-lifed them.
- Other major changes:
- * New html-table runner backed by WebDriver.
- * Unused command line arguments are now no longer parsed.
复制代码
总结一下主要的change 如下:
1. 支持java最低版本1.8
2. 支持FireFox geckodriver
(下载地址:https://github.com/mozilla/geckodriver/releases )类似chrome driver
3. 最低支持IE9
4. 移处旧RC
并无让人心动的变化
Firefox gecko driver:
现在使用Firefox ,如果没有在property设置,将会出现以下Exception
- java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
- at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
- at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
- at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:38)
- at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:91)
- at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
- at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:245)
- at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
- at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
- at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
- at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:128)
- at com.dbyl.libarary.utils.DriverFactory.getFirefoxDriver(DriverFactory.java:126)
- at com.dbyl.tests.getAlert.FireFoxDriver(getAlert.java:24)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:498)
- at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
- at org.testng.internal.Invoker.invokeMethod(Invoker.java:648)
- at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:834)
- at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1142)
- at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
- at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
- at org.testng.TestRunner.privateRun(TestRunner.java:771)
- at org.testng.TestRunner.run(TestRunner.java:621)
- at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
- at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
- at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
- at org.testng.SuiteRunner.run(SuiteRunner.java:259)
- at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
- at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
- at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
- at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
- at org.testng.TestNG.run(TestNG.java:1009)
- at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
- at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
- at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
复制代码
这个时候需要如下设置:
- System.setProperty("webdriver.gecko.driver", "webDriver//geckodriver.exe");
复制代码
Dev Tools 简介1. 使用xpath 定位Web Element
在console 输入:$x("")
[attach]120212[/attach]
2. 使用CSS selector定位web Element在console 里输入:$("")
[attach]120213[/attach]
3. 执行jswindow.alert("")
[attach]120214[/attach]
执行jQuery
- window.getComputedStyle(document.getElementById("su"),null).getPropertyValue("background")
复制代码[attach]120215[/attach]
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) |
Powered by Discuz! X3.2 |