selenium +testNG parallel execution

hi guys,
this stuff is making crazy
I have a set of tests (selenium+testNg ) which are pretty stable when I run them sequentially
The problem is that I want to make them run parallely but, in such case, i have a lot of
“Exception: org.openqa.selenium.WebDriverException: java.lang.InterruptedException: sleep interrupted Build info: version: ‘2.48.2’ ”
Really dont understand why, I was sure multi threading works fine but , seems I have bad karma 🙁
If somebody know about this problem , please let me know and I’ll give all the necess˙ary informations

Thanx

Default Asked on November 27, 2015 in Selenium WebDriver.
Add Comment
  • 4 Answer(s)

    Can you share the code near the Sleep part that you have added. It might be possible that testng is closing the test run and your tests are being killed. Please share the code, we will see how things work.

    Virender

    Professor Answered on November 28, 2015.
    Add Comment

    Just make sure that your webdriver object is not static, otherwise there is a chance that your automation will blew up.
    If that is not the case then as suggested please share the code snippet to help you further.

    Default Answered on November 30, 2015.
    Add Comment

    Also check that your WebDriver Object is not globally declared public variable, it may create problem with global variable at the time of parallel execution with TestNG.

    Train Answered on December 10, 2015.
    Add Comment

    Hi to all,
    Basically my structure it like this one.
    I set my driver in the beforeMethod section, and pass it from my test scripts to the methods i need to use.
    The problem happens for example in the   new WebDriverWait(driver, 60).until(ExpectedConditions.elementToBeClickable(element)) line ( but not only, also in other parts that have some wait !)
    Really don’t know how to fix it so, any idea is a good idea 🙂

    Thanx

    
    *****THIS IS MY TEST SKRIPT***************
    
    public class TEST1 {
    
    private WebDriver driver;
    /*  start  session */
    
    @Parameters({"browser"})
    
    @BeforeMethod
    
    public void beforeMethod(@Optional("CHROME") String browser) throws Exception {
    try {
    
    driver = Configuration.getDriver(browser);
    
    } catch (Exception e) {
    
    }
    
    }
    /*  stop session */
    
    @Parameters("browser")
    
    @AfterMethod
    
    public void afterMethod(@Optional("CHROME") String browser) throws Exception {
    try {
    
    driver.quit();
    
    } catch (Exception e) {
    
    }
    
    }
    @Test(testName = "TEST1", )
    
    public void TEST1() String browser) {
    click(driver);
    
    try {
    
    } catch (Exception e) {
    
    }
    }
    
    }
    *****I HAVE MULTIPLE METHODS FOR DIFFERENT ACTIONS (CLICK,SETTEXT,ETC)***************
    
    public static void click(WebDriver driver) {
    try {
    
    WebElement element = driver.findElement(By.cssSelector(".Control"));
    
    // wait element to be clickable
    
    try {
    
    new WebDriverWait(driver, 60).until(ExpectedConditions.elementToBeClickable(element));
    
    element.click();
    
    }
    
    catch (Exception e) {
    }
    
    }
    *****THIS IS THE METHOD WHERE I INITIALIZE MY DRIVER***************
    
    public class Configuration {
    protected static WebDriver driver;
    
    public static WebDriver getDriver(String browser) throws Exception {
    
    {
    
    WebDriver driver = null;
    
    URL url = new URL("http", "localhost", 4444, "/wd/hub");
    if (browser.equalsIgnoreCase(ConstantsList.BROWSER_FIREFOX)) {
    DesiredCapabilities caps = DesiredCapabilities.firefox();
    
    driver = new ScreenShotRemoteWebDriver(url, caps);
    } else (browser.equalsIgnoreCase(ConstantsList.BROWSER_CHROME)) {
    DesiredCapabilities caps = DesiredCapabilities.chrome();
    
    driver = new ScreenShotRemoteWebDriver(url, caps);
    
    }
    
    return driver;
    
    }
    
    }
    
    }
    
    
    Default Answered on December 23, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.