zoukankan      html  css  js  c++  java
  • selenium3.0 远程模式

    准备工作:

    1. 安装chrome浏览器

    2. 下载selnium-server-standalone-3.0.1.jar

    步骤:

    1. java -jar selnium-server-standalone-3.0.1.jar  (默认ip:localhost、port:4444)

        PS:作为单个server启动时,千万不要画蛇添足加个 -role hub/node

    2.  测试脚本代码:

     1 public class NewTest {
     2     
     3     WebDriver driver;
     4     
     5     DesiredCapabilities desire;
     6 
     7     @Test
     8     public void f() {
     9 
    10         driver.get("http://www.baidu.com");
    11         try {
    12             Thread.sleep(5000);
    13         } catch (InterruptedException e) {
    14             // TODO Auto-generated catch block
    15             e.printStackTrace();
    16         }
    17 
    18     }
    19 
    20     @BeforeMethod
    21     public void beforeMethod() {
    22         desire = DesiredCapabilities.chrome();
    23         try {
    24             driver = new RemoteWebDriver(new URL("http://10.1.7.104:4444/wd/hub"), desire);
    25         } catch (MalformedURLException e) {
    26             // TODO Auto-generated catch block
    27             e.printStackTrace();
    28         }
    29         driver.manage().window().maximize();
    30     }
    31 
    32     @AfterMethod
    33     public void afterMethod() {
    34         driver.quit();
    35     }
    36 
    37 }
    View Code

    注:以上代码所用到的IP为远程设备的IP。启用远程设备上的chrome浏览器,首先在远程设备上启动server(即:cmd--->java -jar selnium-server-standalone-3.0.1.jar),然后在本地执行测试脚本即可远程启动。

  • 相关阅读:
    谷歌浏览器离线安装
    C语言restrict关键字的使用
    Win32编程中radiobutton的分组
    在SourceForge中建立开源项目
    [转载]Linux解压缩命令
    [转载]vim配置文件
    解决VC6在win7下打开文件崩溃问题
    gson解析复杂的json数据
    catch中return语句的执行时间
    踏出了学习clojure的第一步
  • 原文地址:https://www.cnblogs.com/successcai/p/6781294.html
Copyright © 2011-2022 走看看