通過漫長的等待,終於迎來了selenium 3.0 html
從selenium 1.0 至今,差很少有十多年的歷史。這個月終於迎來了selenium3.0 java
那麼selenium3.0 爲咱們帶來了什麼?git
看一下changelog怎麼寫的:github
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 以下:web
1. 支持java最低版本1.8chrome
2. 支持FireFox geckodriver (下載地址:
https://github.com/mozilla/geckodriver/releases )相似chrome drivermaven
3. 最低支持IE9ide
4. 移處舊RCui
並沒有讓人心動的變化this
如今使用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");
在console 輸入:$x("")
在console 裏輸入:$("")
window.alert("")
執行jQuery
window.getComputedStyle(document.getElementById("su"),null).getPropertyValue("background")