Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to run the selenium test in parallel from the virtually created testng.xml using selenium grid
    primarykey
    data
    text
    <p>I used Selenium web driver + TestNG to run my selenium tests in parallel. I used three classes </p> <p><strong>Class One (Main Class) :</strong></p> <p>From this class i am going to start the test. Starting point of my execution.</p> <pre><code> public class MainClass { public WebDriver driver = null; public void gid() { try { CreateTestngXml.gridHubLaunching(); Thread.sleep(10000); } catch (IOException | InterruptedException e) { e.printStackTrace(); } CreateTestngXml.grid("firefox", "chrome"); driver.close(); } public static void main(String a[]) { MainClass ts = new MainClass(); try{ ts.gid(); }catch(Exception e){ e.printStackTrace(); } } } </code></pre> <p><strong>Class Two (CreateTestngXml):</strong></p> <p>public class CreateTestngXml {</p> <pre><code>/** * * @param Brow * @param Brows * @code = To create a TestNg XML suite file and run it. */ public static void grid(String Brow, String Brows) { XmlSuite suite = new XmlSuite(); suite.setName("Compatability"); suite.setVerbose(1); suite.setPreserveOrder("true"); suite.setThreadCount(4); suite.setParallel("tests"); suite.setTimeOut("5000"); // Test XmlTest test = new XmlTest(suite); test.setName("Browser One"); test.addParameter("Browser", Brow); XmlTest testOne = new XmlTest(suite); testOne.setName("Browser Two"); testOne.addParameter("Browser", Brows); List&lt;XmlTest&gt; tests = new ArrayList&lt;XmlTest&gt;(); tests.add(test); tests.add(testOne); // Class List&lt;XmlClass&gt; classes = new ArrayList&lt;XmlClass&gt;(); classes.add(new XmlClass("Grid.CheckGridOne")); test.setXmlClasses(classes); testOne.setXmlClasses(classes); suite.setTests(tests); // Suite List&lt;XmlSuite&gt; suites = new ArrayList&lt;XmlSuite&gt;(); suites.add(suite); TestNG tng = new TestNG(); tng.setXmlSuites(suites); try { // Running the Suite file. tng.run(); } catch (Exception e) { e.printStackTrace(); } } /** * * @throws IOException * @throws InterruptedException * @code = To launch the Grid Hub and Nodes */ public static void gridHubLaunching() throws IOException, InterruptedException { // Launching nodes for each browser. String[] hub = new String[] { "C:\\Windows\\System32\\cmd.exe", "/c", "Start", "Grid-BatchFiles\\hub.bat" }; String[] firefox = new String[] { "C:\\Windows\\System32\\cmd.exe", "/c", "Start", "Grid-BatchFiles\\firefox.bat" }; String[] chrome = new String[] { "C:\\Windows\\System32\\cmd.exe", "/c", "Start", "Grid-BatchFiles\\chrome.bat" }; String[] ie = new String[] { "C:\\Windows\\System32\\cmd.exe", "/c", "Start", "Grid-BatchFiles\\IE.bat" }; Runtime.getRuntime().exec(hub); Thread.sleep(3000); Runtime.getRuntime().exec(firefox); Runtime.getRuntime().exec(chrome); Runtime.getRuntime().exec(ie); } } </code></pre> <p><code>gridHubLaunching()</code> method is used to start the hub and the corresponding browser nodes. It has no problem in creating nodes. I ensured the creation by using <code>http://localhost:4444/grid/console</code></p> <p><strong>Class Third (Grid.CheckGridOne) :</strong></p> <pre><code> public class CheckGridOne { MainClass ts = new MainClass(); WebDriver driver = ts.driver; DesiredCapabilities capability = null; /** * * @param Browser * @throws Exception * @code = To launch a Browser for Compatibility Testing purpose. */ @Test @Parameters({ "Browser" }) public void browserLaunch(String Browser) throws Exception { // Checking condition for a Firefox. if (Browser.equalsIgnoreCase("firefox")) { System.out.println("Firefox"); capability = DesiredCapabilities.firefox(); capability.setBrowserName("firefox"); capability.setPlatform(org.openqa.selenium.Platform.WINDOWS); URL url = new URL(`http://lo***st:4444/wd/hub`); System.out.println("testing"); driver = new RemoteWebDriver(url, capability); System.out.println("test"); } // Checking condition for a iexplorer. if (Browser.equalsIgnoreCase("iexplorer")) { System.out.println("IE"); System.setProperty( "webdriver.ie.driver", "E:\\FW\\Test-2.28.0(Feb-18)\\IEDriverServer\\64-Bit\\IEDriverServer.exe"); capability = DesiredCapabilities.internetExplorer(); capability.setBrowserName("internet explorer"); capability.setPlatform(org.openqa.selenium.Platform.ANY); System.out.println("testing"); driver = new RemoteWebDriver(new URL( `http://lo***st:4444/wd/hub`), capability); System.out.println("test"); } // Checking condition for a chrome. if (Browser.equalsIgnoreCase("chrome")) { System.out.println("chrome"); } } } </code></pre> <p>By using the above three class i tried to run the selenium tests in parallel. My problem is it is working fine before it reaches the <code>driver = new RemoteWebDriver(url, capability);</code> in the class third. Once it reaches the line it terminates the <code>TestNG suite file</code>. I don't know whats the problem is on my code?</p> <p><strong>Output:</strong></p> <pre><code> [TestNG] Running: Command line suite Firefox IE testing testing =============================================== Compatability Total tests run: 0, Failures: 0, Skips: 0 =============================================== test test </code></pre> <p>The output shows the total test run as <code>0</code>. I don't know why it is showing like that.</p> <p>Selenium Server - 2.28.0<br> TestNG - 6.1.1 &amp; 6.8<br> IEDriverServer - 2.28.0</p> <p>I know the question is bit big. I thought this is the correct way to explain clearly. Any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload