0

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>

enter image description here

enter image description here

Javed Ahmed
  • 223
  • 1
  • 3
  • 17
  • It still is not clear what your issue is. A browser cannot be launched on the Hub (the codebase doesnt have support for that kind of thing), unless and until you have a node also running on the same machine as the hub. Would it be possible for you to add context such that the issue is much more clear. – Krishnan Mahadevan Oct 27 '17 at 03:16
  • Thank you @KrishnanMahadevan for your reply. I will add details shortly. – Javed Ahmed Oct 27 '17 at 03:22
  • @KrishnanMahadevan can you please check now the details I have added. So I am just trying to run these test and those are running on hub instead of node. Also those are launching firefox (which i have not configured anywhere). – Javed Ahmed Oct 27 '17 at 03:59
  • Can you also please add details on how the node and hub are being spun off, because I guess that is probably the place which is fishy. – Krishnan Mahadevan Oct 27 '17 at 04:26
  • @KrishnanMahadevan for Hub I have installed Selenium plugin in the jenkins (which is on linux machine) For node I have downloaded the Selenium stand alone on windows machine and started node using the command. – Javed Ahmed Oct 27 '17 at 10:42
  • @KrishnanMahadevan I have added the pictures in main thread of this question . Please take a look – Javed Ahmed Oct 27 '17 at 10:48

0 Answers0