zoukankan      html  css  js  c++  java
  • selenium grid 使用方法

    代码和selenium driver相同 只是 启动环境方式不同。至少启动一个hub 一个 node 。如需要多个,可以使用端口进行区分。

    1. java -jar selenium-server-standalone-x.xx.x.jar -role node -port 5555  
    2. java -jar selenium-server-standalone-x.xx.x.jar -role node -port 5556  
    3. java -jar selenium-server-standalone-x.xx.x.jar -role node -port 5557
    4. 代码如下

    WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap); 

    //test01: 只匹配Windows下的ie来执行此用例,版本不限;多个版本匹配成功时优先级暂未知  

    1. DesiredCapabilities aDesiredcap = DesiredCapabilities();  
    2. aDesiredcap.setBrowserName("internet explorer")  
    3. aDesiredcap.setVersion("")  
    4. aDesiredcap.setPlatform(Platform.WINDOWS)  
    5. WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);  
    6. wd.doSomething()  
    7.   
    8. //test02: 只匹配linix下的firefox的版本为22的浏览器执行用例;    
    9. DesiredCapabilities aDesiredcap = DesiredCapabilities("firefox""22", Platform.LINUX);  
    10. WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);  
    11. wd.doSomething()      
    12.   
    13. //test03: 只匹配MAC下的safari浏览器执行,版本不限    
    14. DesiredCapabilities aDesiredcap = DesiredCapabilities.safari();  
    15. aDesiredcap.setPlatform(Platform.MAC)  
    16. WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);  
    17. wd.doSomething()      
    18.   
    19. //test04: 只匹配chrome浏览器,任意平台,任意版本  
    20. DesiredCapabilities aDesiredcap = DesiredCapabilities.chrome();  
    21. aDesiredcap.setPlatform(Platform.ANY)  
    22. WebDriver wd = new RemoteDriver("http://localhost:4444/wd/hub", aDesiredcap);  
    23. wd.doSomething() 
  • 相关阅读:
    Mybatis实现数据的增删改查(CRUD)
    Spring MVC基础入门
    Swap in C C++ C# Java
    java和c#使用hessian通信
    基于Netty4的HttpServer和HttpClient的简单实现
    RabbitMQ的几种典型使用场景
    java多线程编程
    singleton pattern的推荐实现
    python多线程编程
    基于GMap.Net的地图解决方案
  • 原文地址:https://www.cnblogs.com/wcLT/p/3394375.html
Copyright © 2011-2022 走看看