vendredi 25 septembre 2020

Run multiple browser with Selenium Grid

I try to run multiple browsers (5 instances of chrome and 5 instances of firefox) in parallel on two different nodes with selenium grid. Unfortunately I got two errors:

org.openqa.selenium.WebDriverException: invalid argument: can't kill an exited process
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Here's my code:

BaseTest.java

public class BaseTest {
    RemoteWebDriver driver; 
    @Parameters({"Port"})
    @BeforeClass
    public void initiateDriver(String Port) throws MalformedURLException {
        
        
        if(Port.equalsIgnoreCase("9001"))
        {
            driver = new RemoteWebDriver(new URL("http://81.xxx.180.xxx:4444/wd/hub"), DesiredCapabilities.chrome());
        }
        else if(Port.equalsIgnoreCase("9002"))
        {
            driver = new RemoteWebDriver(new URL("http://81.xxx.180.xxx:4444/wd/hub"), DesiredCapabilities.firefox());
        }
    }
                
     @AfterClass
     public void shutDown()
     {
         driver.quit();
     }
}


FirstTest.java

public class FirstTest extends BaseTest {
    
    @Test
    public void Test() throws InterruptedException, MalformedURLException {
        System.out.println("Test before URL"); 
        driver.get("https://google.de");
        System.out.println("Test after URL");
    }
}

seleniumgridparallel.xml

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite thread-count="10" name="SeleniumGridDocker" parallel="tests">

    <test name="Chrome Test">
        <parameter name="Port" value="9001" />
        <classes>
            <class name="grid.FirstTest" />
        </classes>
    </test>

    <test name="Chrome Test 2">
        <parameter name="Port" value="9001" />
        <classes>
            <class name="grid.FirstTest" />
        </classes>
    </test>
    
    <test name="Chrome Test 3">
        <parameter name="Port" value="9001" />
        <classes>
            <class name="grid.FirstTest" />
        </classes>
    </test>
    
    <test name="Chrome Test 4">
        <parameter name="Port" value="9001" />
        <classes>
            <class name="grid.FirstTest" />
        </classes>
    </test>

    <test name="Chrome Test 5">
        <parameter name="Port" value="9001" />
        <classes>
            <class name="grid.FirstTest" />
        </classes>
    </test>
    
    <test name="Firefox Test 1">
        <parameter name="Port" value="9002" />
        <classes>
            <class name="grid.FirstTest" />
        </classes>
    </test>
    
    <test name="Firefox Test 2">
        <parameter name="Port" value="9002" />
        <classes>
            <class name="grid.FirstTest" />
        </classes>
    </test>
    
    <test name="Firefox Test 3">
        <parameter name="Port" value="9002" />
        <classes>
            <class name="grid.FirstTest" />
        </classes>
    </test>
    
    <test name="Firefox Test 4">
        <parameter name="Port" value="9002" />
        <classes>
            <class name="grid.FirstTest" />
        </classes>
    </test>
    
    <test name="Firefox Test 5">
        <parameter name="Port" value="9002" />
        <classes>
            <class name="grid.FirstTest" />
        </classes>
    </test>
</suite>

Selenium Grid

It would be great if someone of you has a solution for my problem. Or is there a misunderstand from my side using Selenium Grid?

Thank you...

Aucun commentaire:

Enregistrer un commentaire