RE: Testng execution failed

Answered

 


package Date;
import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.testng.annotations.Parameters;

import org.testng.annotations.Test;

import org.testng.annotations.BeforeClass;

import org.testng.annotations.AfterClass;
public class NewTest {

WebDriver d;

@Parameters("browser")
@Test

public void test() {
d.findElement(By.id("txtUserName")).click();

d.findElement(By.id("Password")).click();

d.findElement(By.className("button postfix")).click();
}

@BeforeClass

public void beforeClass(String browser) {
if(browser.equalsIgnoreCase("firefox"))

{

d=new FirefoxDriver();

}

else if(browser.equalsIgnoreCase("chrome"))

{

System.setProperty("WebDriver.chrome.driver", "D:\\Testing Softwares\\chromedriver.exe");

d= new ChromeDriver();

}

d.get("http://www.univoxcommunity.com");

}
@AfterClass

public void afterClass() {
d.quit();

}
}

Testng.xml :


 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="false">
<test name="FirefoxTest">
<parameter name="browser" value="firefox" />
<classes>
<class name="Date.NewTest" />
</classes>
</test>
<test name="chromeTest">
<parameter name="browser" value="ie" />
<classes>
<class name="Date.NewTest" />
</classes>
</test>
</suite>

snpanigrahi9 Train Asked on September 7, 2014 in Selenium WebDriver.

hi
please post the error you are getting

on September 8, 2014.
Add Comment
1 Answers
Best answer

Now check. Below highlighted are the changes.

And let me know the result 🙂 .


@Test
public void test() {

d.findElement(By.id("txtUserName")).click();
d.findElement(By.id("Password")).click();
d.findElement(By.className("button postfix")).click();

}

 

@BeforeClass

@Parameters("browser") //You have given at @Test annotation

public void beforeClass(String browser) {

if(browser.equalsIgnoreCase("firefox"))
{
d=new FirefoxDriver();
}
else if(browser.equalsIgnoreCase("chrome"))
{
System.setProperty("webdriver.chrome.driver", "D:/Selenium/Drivers/chromedriver.exe"); //Should be small letters always (webdriver)
d= new ChromeDriver();
}
d.get("http://www.univoxcommunity.com");
}

Thanks,
Sachin

Vice Professor Answered on September 16, 2014.
Add Comment

Your Answer

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