51Testing软件测试论坛

标题: selenium3 beta初体验 [打印本页]

作者: 测试积点老人    时间: 2018-12-18 15:28
标题: selenium3 beta初体验
本帖最后由 测试积点老人 于 2018-12-18 15:30 编辑

从selenium 1.0 至今,差不多有十多年的历史。

那么selenium3.0 为我们带来了什么?

看一下changelog怎么写的:

  1. v3.0.0-beta2
  2. ============

  3. * maven packaging fixes
  4. * Update GeckoDriver --port argument in all bindings
  5. * System property webdriver.firefox.marionette now forces the server in marionette or legacy firefox driver mode, ignoring any related Desired Capability
  6. * Grid fix NPE's on registration when -browser not specified

  7. v3.0.0-beta1
  8. ============

  9. IMPORTANT CHANGES

  10. * Minimum java version is now 8+
  11. * The original RC APIs are only available via the leg-rc package.
  12. * To run exported IDE tests, ensure that the leg-rc package is on the
  13.   classpath.
  14. * Support for Firefox is via Mozilla's geckodriver. You may download
  15.   this from https://github.com/mozilla/geckodriver/releases
  16. * Support for Safari is provided on macOS (Sierra or later) via
  17.   Apple's own safaridriver.
  18. * Support for Edge is provided by MS:
  19.   https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
  20. * Official support for IE requires version 9 or above. Earlier
  21.   versions may work, but are no longer supported as MS has
  22.   end-of-lifed them.

  23. Other major changes:

  24. * New html-table runner backed by WebDriver.
  25. * 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

  1. 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
  2.     at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
  3.     at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
  4.     at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:38)
  5.     at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:91)
  6.     at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
  7.     at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:245)
  8.     at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
  9.     at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
  10.     at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
  11.     at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:128)
  12.     at com.dbyl.libarary.utils.DriverFactory.getFirefoxDriver(DriverFactory.java:126)
  13.     at com.dbyl.tests.getAlert.FireFoxDriver(getAlert.java:24)
  14.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  15.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  16.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  17.     at java.lang.reflect.Method.invoke(Method.java:498)
  18.     at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
  19.     at org.testng.internal.Invoker.invokeMethod(Invoker.java:648)
  20.     at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:834)
  21.     at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1142)
  22.     at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
  23.     at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
  24.     at org.testng.TestRunner.privateRun(TestRunner.java:771)
  25.     at org.testng.TestRunner.run(TestRunner.java:621)
  26.     at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
  27.     at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
  28.     at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
  29.     at org.testng.SuiteRunner.run(SuiteRunner.java:259)
  30.     at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
  31.     at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
  32.     at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
  33.     at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
  34.     at org.testng.TestNG.run(TestNG.java:1009)
  35.     at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
  36.     at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
  37.     at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
复制代码

这个时候需要如下设置:

  1. 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. 执行js

window.alert("")


[attach]120214[/attach]


执行jQuery

  1. window.getComputedStyle(document.getElementById("su"),null).getPropertyValue("background")
复制代码

[attach]120215[/attach]









欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2