testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.98k stars 1.02k forks source link

Test execution hangs between two consecutive tests that use same dataProvider #1422

Closed serpro69 closed 7 years ago

serpro69 commented 7 years ago

TestNG Version

6.11

Expected behavior

Tests running one after another without interruption

Actual behavior

test1() runs successfully, after that test2() hangs for 5+ minutes (but resumes if I manually interact with browser)

Is the issue reproductible on runner?

Test case sample

I have two test cases that run one after the other and both use same dataProvider, and a @BeforeMethod that verifies the state of the page before executing test method.

After first test case passes, @BeforeMethod starts, verification (simply checking that header is correct) passes, PageObject Factory is getting initialized for Page that is used in DataProvider and test execution just hangs for a very long time. If I interact with the browser manually, then test execution resumes. I've tried executing test1(), testX() (w/o dataProvider), then test2() and everything works fine.

@DataProvider
    public static Object[][] mandatoryFieldsErrors() {
       PageObject page= new PageObject(driver);

        return new Object[][]
                {
                        {page.inputFieldWebElement1, page.errorMessageWebElement1, "String to verify error message is correct"},
                        {page.inputFieldWebElement2, page.errorMessageWebElement2, "String to verify error message is correct"},
                };
    }

@BeforeMethod
    public void beforeMethod() {

    //here is just a verification that user is on correct page before proceeding to executing the test case
}

@Test(description = "Verify mandatory fields",
            dataProviderClass = TestNGDataProvider.class, dataProvider = "mandatoryFieldsErrors")
    public void test1(WebElement textFieldElement,
                            WebElement errorMessageElement,
                            String sExpectedErrorMessage) throws Exception {

// here driver clicks on web element input field
// then clicks outside of element for the error message to appear
// verify if error message is displayed and correct
}

@Test(description = "Verify mandatory fields",
            dataProviderClass = TestNGDataProvider.class, dataProvider = "mandatoryFieldsErrors")
    public void test2(WebElement textFieldElement,
                            WebElement errorMessageElement,
                            String sExpectedErrorMessage) throws Exception {

// in this test driver just clicks on 'submit' button 
// verify that errors are displayed for all mandatory fields that are empty
}

@Test
public void test3() {
//...
}
cbeust commented 7 years ago

Do you have evidence the hang up is happening in TestNG and not Selenium?

serpro69 commented 7 years ago

No, I don't. How can I verify that?

cbeust commented 7 years ago

Get a stack trace during the freeze and see who is waiting. I'll close this issue for now, please reopen once you have something like that showing an issue in TestNG.