51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1894|回复: 0
打印 上一主题 下一主题

selenium3 beta初体验

[复制链接]
  • TA的每日心情
    无聊
    前天 09:06
  • 签到天数: 530 天

    连续签到: 2 天

    [LV.9]测试副司令

    跳转到指定楼层
    1#
    发表于 2018-12-18 15:28:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    本帖最后由 测试积点老人 于 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("")




    2. 使用CSS selector定位web Element

    在console 里输入:$("")




    3. 执行js

    window.alert("")



    执行jQuery

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




    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing

    x
    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-23 05:00 , Processed in 0.066511 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表