Running As Test NG / Java app

Answered

I’m refactoring my tests so basically starting from the beginning. I started a little differently as I have a main class

public static void main(String[] args) throws Exception {

OpenBrowser();
login();
SFTab();
accountSearch();

}

@Test

public static void OpenBrowser() {

CODE here

}

@Test

public static void login() {

CODE here

}

@Test

public static void SFTab() {

CODE here

}

and so on. When I Run As Java application its fine. Which,  from my understanding is running from the Main. When I Run As Test NG it fails some of the tests stating  that it can’t find an element.  Some of the methods pass fine.  I’m wondering why it would fail as Test NG but not as a Java App. I’m calling the same code.

Train Asked on September 10, 2015 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)
    Best answer

    Ok, I added (priority = 0) 1, 2 and so on which fixed it. apparently It needs an order to run?

    Train Answered on September 10, 2015.
    Add Comment
  • Your Answer

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