开发者

Multi-Test TestNG.xml file results in java.lang.NullPointerException

Multi-Test TestNG.xml file results in java.lang.NullPointer开发者_Python百科Exception

Hello Quality Team,

I need help getting TestNG to run multiple tests from one XML file. So far my efforts to do this result in a java.lang.NullPointerException OR the test(s) fake_execute="says it ran...but how can it have run if it didn't start selenium?"

One final note: All of the tests run SUCCESSFULLY when run using a stand-alone XML file

Below is my XML file

   <test name="Simple example">
       <groups>
       <run>
   <include name="groupA" />
   <include name="groupB" />
       </run>
   </groups>
   <classes>
      <class name="test.LoginPageTest"/>
      <class name="test.PurchaseItemTest"/>
     </classes>
   </test>
</suite>

When TestNG/Selenium throws the Null Pointer Error it is always failing on a selenium.open(URL), selenium.windowMaximize(), selenium.windowFocus().

I use a SeleneseTestNGHelper file that starts Selenium and handles some base-level selenium functionality.

Here is the command from the Test that my test is failing on

@Test (dataProvider = "Login_Test", groups = {"groupA"})
 public void testLoginPage(String string1, String string2) throws Exception { 
 // Super-size & Focus on Selenium Test Window
 //selenium.windowMaximize();
 //selenium.windowFocus();

        // Start your motors and get to testing
        try {  selenium.open("http://www.google.com");  }
        catch(Throwable e)
        {e.printStackTrace(); }
}

Here is the method called

 public void open(String string) {
  selenium.open(string);
  selenium.windowMaximize();
  selenium.windowFocus();
 }


I don't see any code that actually initializes your selenium field, where is this happening?

Wherever it is, make sure it's initialized in a @BeforeMethod or @BeforeClass.

Also, here is some relevant documentation:

http://testng.org/doc/selenium.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜