Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

0
Session problem in selenium grid while running multiple testcases on multiple browser parallely

Solved 1 Answers 76 Views Selenium
0 1
Hi ,

I am running 2 testcases on chrome and firefox
It start with 1 st testcase on chrome and  firefox parallely then once chrome completed
and close the browser mean while firefox session will go off and
start 2nd testcase on both chrome and firefox browser.

1st firefox browser wont run whole testcase execution

Can you suggest any solution ?

1 Answer

0
Best answer
0
Problem shows that your webdriver instance is being. It looks like either you are making your webdriver variable as static. Batter approach is to delcare and define webdriver instance inside @Test method.

 

Can you post your code which you're using to initiate webdriver object? It will help to provide detailed solution.
answered by (151 points)
selected by
6Comments
commented by (14 points)
driver variable getting null, cant proceed to execution of process.
commented by (151 points)
i think you should debug your code. What values you are passing for browser and URL?
commented by (14 points)
hi,
i have debugged and solved , but same issue facing .

public WebDriver openBrowser(String vBrowser, String vHubUrl,WebDriver driver) throws IOException, InterruptedException {
        //browsertype browserType = browsertype.valueOf(vBrowser);
        //String userDir = System.getProperty("user.dir");
        //StringBuilder filename = new StringBuilder();
        DesiredCapabilities capability = null;
        switch (browsertype.valueOf(vBrowser)) {
        case IE:
            capability = DesiredCapabilities.internetExplorer();
            capability.setBrowserName("internet explorer");
            capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
            capability.setPlatform(org.openqa.selenium.Platform.WINDOWS);
            capability.setCapability(
                    InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
            capability.setJavascriptEnabled(true);
            break;

        case CHROME:

            capability = DesiredCapabilities.chrome();
            ChromeOptions options = new ChromeOptions();
            options.addArguments("test-type");
            options.addArguments("start-maximized");
            capability.setCapability(ChromeOptions.CAPABILITY, options);
            break;

        case FF:
            capability = DesiredCapabilities.firefox();
            break;

        case SAFARI:
            capability = DesiredCapabilities.safari();
            break;
        }
         
         driver = new RemoteWebDriver(new URL(vHubUrl), capability);
         System.out.println(driver);
         DriverSetUp setup= new DriverSetUp();
         setup.setDriver(driver);
         driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
         driver.manage().window().maximize();
         return setup.getDriver();
       
    }


public class DriverSetUp {

   private WebDriver driver;

    public WebDriver getDriver() {
        return driver;
    }

    public void setDriver(WebDriver driver) {
        this.driver = driver;
    }
   
}


Keyword code

WebDriver driver1;
    public void executeKeywords(WebDriver driver) throws Exception
    {   
   
        switch(vKW){
        case "openBrowser":
            driver1=openBrowser(vBrowser, vHubUrl,driver);
            implicitWait();
            break;
        case "enterSite":
            enterSite(driver1);
            break;
        case "closeBrowser":
            driverQuit(driver1);
            break;
    }
commented by (14 points)
Without creating getter n setter class(driversetup), just return webDriver from open browser , same issue facing .
commented by (151 points)
Creating get and set methods is not the solution. You need to create debug point at very beginning and understand where your code is flowing.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...