简体   繁体   English

在一台机器(Chrome和Firefox)中的2个浏览器中运行硒网格测试

[英]Run selenium grid test in 2 browser in one machine(Chrome and Firefox)

I have few tests, i want to run the tests on both Chrome and firefox. 我的测试很少,我想同时在Chrome和firefox上运行测试。

How can i do that? 我怎样才能做到这一点?

My code is: 我的代码是:

   @Test   //Test1
        public  void logInFaildTest() {
            GridTest gridTest = new GridTest();
            WebDriver webDriver = gridTest.getWebDriver();//get driver 
            LoginPage logIn = new LoginPage(webDriver, url);
            String userName = "user";
            String pass="pass";
             ......................................
            webDriver.close();
        }
   }

Create an xml file, testing.xml with the desired parameters and add a Parameters annotation (@Parameters) over your loginfailed method. 创建一个具有所需参数的xml文件testing.xml,并在您的loginfailed方法上方添加一个Parameters批注(@Parameters)。 That would pass all the desired parameters required for your tests 这将通过测试所需的所有所需参数

Your testing.xml might look like : 您的testing.xml可能看起来像:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="TestSuite" thread-count="2" parallel="tests" >

<test name="ChromeTest">

<parameter name="browser" value="Chrome" />

<classes>

<class name="<your class name here>">

</class>

</classes>

</test>

<test name="FirefoxTest">

<parameter name="browser" value="Firefox" />

<classes>

<class name="<Your class name here>">

</class>

</classes>

</test>

<test name="IETest">

<parameter name="browser" value="IE" />

<classes>

<class name="<Your class name here>">

</class>

</classes>

</test>

</suite>

The above xml runs tests in parallel threads across all the three given browsers. 上面的xml在所有三个给定的浏览器中以并行线程运行测试。 In your java code, you should pass the parameters from testing.xml like 在您的Java代码中,您应该像这样传递来自testing.xml的参数

@Parameters("browser")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 多个Selenium Grid 2测试:如何在带有隐藏Windows浏览器的Firefox中运行 - Multiple Selenium Grid 2 Test: how to run in Firefox with hidden windows Browser 在同一台机器上打开五个Firefox-硒网格 - open five firefox in same machine - selenium grid 如何仅在硒网格中运行一种测试方法 - How to run one test method only in selenium grid Java-无法在Firefox浏览器中使用Selenium网格 - Java - Unable to use selenium grid with firefox browser 使用 Selenium 网格和 Java、Firefox 和 Chrome 在 Mac 上运行流畅,但 Safari 在页面底部中断 - 不会滚动 - Using Selenium Grid and Java, Firefox and Chrome run smoothly on Mac, but Safari breaks at bottom of the page - won't scroll 无法使用 Selenium Webdriver java 在 Linux 机器上运行 Headless Chrome 浏览器 - Unable to run Headless Chrome Browser on Linux Machine using Selenium Webdriver java 在同一台机器上运行 selenium 网格集线器和节点 - Run selenium grid hub and node the same machine Selenium RC:我无法在firefox或任何其他浏览器中运行测试套件 - Selenium RC: I am unable run test suite in firefox or any other browser 如何在Firefox的默认浏览器中运行Selenium - How to run the selenium in default browser of firefox 如何在Chrome或Firefox浏览器上运行javascript - How to run javascript on Chrome or Firefox browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM