NullPointer exception in TestNG while run test using xml

Try to automate my test using TESTNG framework in eclipse.
In Project I use one packet iEDGE and write all test methods in single Class named eLogin.
But when I try to execute the code it shows nullPointer exceptions.
Following is my sample code and xml settings that I use to run my test case.

Can any one help me to resolve my problem.

Package com.iEDGE;
public class eLogIn {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();     

@Parameters ( { "platform", "browser", "ver" } )
@BeforeMethod (alwaysRun=true )
public void setUp(@Optional String platform  , @Optional String  browser   , @Optional String version     ) throws Exception {
baseUrl = "Gmail URL";              
DesiredCapabilities mCapability = new DesiredCapabilities();        

if (platform.equalsIgnoreCase("WINDOWS")){
    mCapability.setPlatform(org.openqa.selenium.Platform.WINDOWS);
}

if (browser.equalsIgnoreCase("Firefox")) {
mCapability = DesiredCapabilities.firefox();
mCapability.setVersion("40");           
}

driver = new RemoteWebDriver(new URL(baseUrl), mCapability);            
driver.manage().timeouts().implicitlyWait(1000, TimeUnit.MILLISECONDS);           
driver.get(baseUrl);       
driver.findElement(By.cssSelector("input[name=username]")).clear();
driver.findElement(By.cssSelector("input[name=username]")).sendKeys("username");
driver.findElement(By.cssSelector("input[name=password]")).clear();
driver.findElement(By.cssSelector("input[name=password]")).sendKeys("password");
driver.findElement(By.id("button-1015-btnInnerEl")).click();
}
//OTEHR TEST METHODS ....
}     

TESTSuite.xml Settings

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite guice-stage="DEVELOPMENT" name="Default suite">
<test verbose="2" name="Default test">                  
<parameter name="platform" value="Windows"/>
    <parameter name="browser" value="Firefox"/>
    <parameter name="ver" value="40.0.3"/>                      
<classes>
  <class name="com.iEDGE.eLogIn"/>
</classes>
</test> <!-- Default test -->
</suite> <!-- Default suite -->


Source: xml

Leave a Reply