Tests are skipping unexceptedly in selenium webdriver.

2,038 views
Skip to first unread message

Sonu

unread,
Dec 5, 2013, 3:03:23 AM12/5/13
to testng...@googlegroups.com
I am trying to execute 10 test classes with one tests. Here some time the executions of classes are upto 2/3 classes after that all are classes are skipping due to non catch exception. And my driver instance also may be not able to drive rest classes setUp method. In setUp method there is exception called unreachable browser.Here the real browser is not closed but still it is showing Error communicating with the remote browser. It may have died.

I have script like :

Super class:
public class NewTest {
   
   
    public static WebDriver driver;
    public static String userName=null;
    public static String passWord=null;
    public static String baseURL=null;
    static Login login = new Login();
    static Logout logout = new Logout();
   
   
   
   
   
    @BeforeTest(alwaysRun=true)
    @org.testng.annotations.Parameters({ "username", "password","url","browser"})                     
    public static void setUp(String uname,String pwd,String baseUrl,String browser) throws Exception {

        System.out.println("Hii");
        userName=uname;
        passWord=pwd;
        baseURL=baseUrl;
       
        if(browser.equalsIgnoreCase("firefox"))
        {
            driver = new FirefoxDriver();
        }
        //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.manage().window().maximize();
        driver.get(baseUrl);
        login.loginFunc(driver,uname,pwd);
    }

    @AfterTest
    public void afterClass() throws NoSuchElementException, Exception {

        logout.logoutFunc(driver);
        driver.close();
        driver.quit();
    }

}

Test class:

public class RoleFunctional extends NewTest{
   
    public static WebDriver driver;
@BeforeClass(alwaysRun=true)
    public static void setUp() throws Exception {

        driver=NewTest.driver;
}

@Test(priority=1)
public void test1()
{
}
@Test(priority=2)
public void test2()
{
// SOME TIME IT THROW ARRAY INDEX OUT OF BOUND WHICH I AM NOT CATCHING
}
@Test(priority=3)
public void test3()
{
}









johannga...@gmail.com

unread,
Apr 8, 2014, 12:54:04 PM4/8/14
to testng...@googlegroups.com
Hi Sonu,

I get the same issue and I don't find any answer on the web..
Did you get any answer?

Johann

Ramshankar Behera

unread,
Apr 9, 2014, 2:25:09 AM4/9/14
to testng...@googlegroups.com
Yes I got the answer.

Actually when any error/exception comes that time the program ends the whole execution of that program. So you need to handle the exception properly and write the individual beforeclass and afterclass for each instead of before suite and after suite.

Thanks,
Sonu.




--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/WLt-feLpkaM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

johannga...@gmail.com

unread,
Apr 9, 2014, 2:43:07 PM4/9/14
to testng...@googlegroups.com
Hi Sonu,

First thank you for your answer ;-)

How to handle this exception? Do you have any before class and after class example to provide?

Thks!

Ramshankar Behera

unread,
Apr 10, 2014, 1:28:31 AM4/10/14
to testng...@googlegroups.com
Hi,

There are various reasons why TestNG is skipping the tests. May I know what are you trying to do here. 

I mean how your code template looks ? 

If you can explain then it would easy to trigger.


Thanks,
Ramshankar.

Shawn McCarthy

unread,
Apr 10, 2014, 10:01:37 AM4/10/14
to testng...@googlegroups.com
I have seen a similar issue, where some tests were getting skipped. For me, it was my BeforeTest that was throwing an exception, so every new test that used that same BeforeTest, would be skipped. I think with TestNG, if the BeforeTest fails, than it is assumed that any other test that uses that same BeforeTest, it will fail again. I solved this by putting my BeforeTest in a try/catch, so I caught every exception that could be thrown from the BeforeTest, and than in your @Test, right at the top, you can assert that the BeforeTest did what it was suppose to do, before beginning the actual test.

djangofan

unread,
Apr 18, 2014, 9:56:00 PM4/18/14
to testng...@googlegroups.com
Yes, TestNG will Skip ( aka SkipException) usually when an exception is thrown in any of the @Before methods right?  But, a skip wont occur if exception occurs in the @Test methods body.  I wish the documentation was better in this area because it forces us to write entire unit tests just to learn the behavior of TestNG.
Reply all
Reply to author
Forward
0 new messages