Selenium Grid - Tests are running sequentially | Selenium Forum
M
Mahanthi Kanakamedala Posted on 25/01/2021

Tests are running sequentially and in addition to that elements are not accesible when tests are run using the Grid(These run successfully when run individually(without grid):

Following the code block for the grid

public void openBrowser() throws MalformedURLException {
System.out.println("Opening " + data.get(dataKey) + " Browser");
test.log(Status.INFO, "Opening " + data.get(dataKey) + " Browser");
if (prop.getProperty("grid").equals("y")) {
URL remoteAddress = new URL("xxx");
if (data.get(dataKey).equals("Chrome")) {
ChromeOptions capabilities = new ChromeOptions();
capabilities.addArguments("--start-maximized");
driver = new RemoteWebDriver(remoteAddress, capabilities);
} else if (data.get(dataKey).equals("Firefox")) {
FirefoxOptions capabilities = new FirefoxOptions();
driver = new RemoteWebDriver(remoteAddress, capabilities);
}

}

Please let me know if I am missing something.


A
Ashish Thakur Replied on 28/01/2021

if (prop.getProperty("grid").equals("y")) 

 

y - May be its in upper case in prop file  "Y"


M
Mahanthi Kanakamedala Replied on 28/01/2021

I have mentioned grid=y in the properties file. 
I can see that the tests are running on 2 nodes but sequentially.

 


A
Ashish Thakur Replied on 30/01/2021

driver = new RemoteWebDriver(remoteAddress, capabilities);

 

should not be in if and else

it should be after if and else


M
Mahanthi Kanakamedala Replied on 10/02/2021

I have update the code as below, even then the tests are running sequentially:

public void openBrowser() throws MalformedURLException {


System.out.println("Opening " + data.get(dataKey) + " Browser");
test.log(Status.INFO, "Opening " + data.get(dataKey) + " Browser");

if (prop.getProperty(Constants.GRID_PROPERTY_VAR).equals(Constants.GRID_YES)) {
URL remoteAddress = new URL("http://xxx.xxx.xxx.xx:4444/wd/hub");
ChromeOptions capabilities = new ChromeOptions();
capabilities.addArguments("--start-maximized");
driver = new RemoteWebDriver(remoteAddress, capabilities);
}

else {

if (data.get(dataKey).equals(Constants.BROWSER_CHROME)) {
driver = new ChromeDriver();
} else if (data.get(dataKey).equals(Constants.BROWSER_FIREFOX)) {
driver = new FirefoxDriver();
} else if (data.get(dataKey).equals(Constants.BROWSER_IE)) {
driver = new InternetExplorerDriver();
}

}
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();

}


M
Mahanthi Kanakamedala Replied on 13/02/2021

SuiteA.xml file I missed adding parallel ="tests" in the <suite> tag. After adding this 2 tests started running parallelly. 
However the loading of  the page took longer and most of the actions failed due to that.
Once a test failed in a node , the rest of the tests are run in the other node sequentially.


A
Ashish Thakur Replied on 13/02/2021

Which version of standalone jar are you using


M
Mahanthi Kanakamedala Replied on 14/02/2021

I have used the jar that my instructor shared during the course, I am not sure about the version. Please find attached the server jar


M
Mahanthi Kanakamedala Replied on 14/02/2021

Dependencies used for the project:

<dependencies>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- TestNG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.3.0</version>
</dependency>
<!-- POI -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.20</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>SparseBitSet</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire</artifactId>
<version>2.18.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.3</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.4.1</version>
</dependency>
<!-- Java mail api -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>

<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>saxon</artifactId>
<version>8.7</version>
</dependency>

<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.2</version>
</dependency>


Related Posts