I have configured my hub and one of the node. Hub is setup on jenkins as a plugin which is running on ubundu machine and my node is running on windows machine. Hub and node are correctly configure. Now when I am running the test to launch the chrome browser on node it is behaving weird. The one browser instances is launched on the node and not redirected to url. After few seconds it launches the Firefox browser's 5 instances on hub node. (Although i have setup only chrome capabilities).
Has anyone else faced the similar issue ? For reproducing the same issue I have created 2 sample classes and one testng.xml file.
TestClass.java
import com.codeborne.selenide.Selenide;
import org.testng.annotations.Test;
public class TestClass extends ParentClass {
@Test
public void testcase1(){
Selenide.open("http://www.google.com"); }
@Test
public void testcase2(){
Selenide.open("http://www.ymail.com");
}
@Test
public void testcase3(){
Selenide.open("http://www.bbc.com");
}
}
ParentClass.java
import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.WebDriverRunner;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import java.net.MalformedURLException;
import java.net.URL;
public class ParentClass {
Logger LOG = LoggerFactory.getLogger(ParentClass.class);
@BeforeTest
@Parameters({"Browser", "hubAddress"})
public void setupBrowser(@Optional("chrome") String browser, @Optional("") String hubAddress) {
LOG.info("Setting up Browser: ");
WebDriver driver=null;
if (browser.equalsIgnoreCase("chrome")) {
if (!hubAddress.equals("")){
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setBrowserName("chrome");
driver= setUpRemoteBrowser(hubAddress,cap);
WebDriverRunner.setWebDriver(driver);
}
}
Configuration.startMaximized = true;
Configuration.timeout = 10;
LOG.info("Browser Setup completed");
}
public WebDriver setUpRemoteBrowser(String hubUrl, DesiredCapabilities capabilities){
LOG.info("Running browser using hub");
WebDriver driver =null;
try {
driver = new RemoteWebDriver(new URL(hubUrl), capabilities);
}
catch (MalformedURLException e){
LOG.info("Incorrect URL");
e.printStackTrace();
}
return driver;
}
}
testng.xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="hue-test-Suite" parallel="true">
<parameter name="Browser" value="chrome"/>
<parameter name="hubAddress" value="http://172.26.158.157:4444/wd/hub"/>
<test name="HueMailSmoke-Tests">
<classes>
<class name="TestClass">
</class>
</classes>
</test>
</suite>