Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

0
Getting the error

Solved 1 Answers 57 Views Selenium
0 1
Hi,
     I get this error when i try try run my tests as TestNg through eclipse. 
Here is my code where i call the browser and also the xml file is below that. 
 
code
 
public class TC {
WebDriver driver;
 
@BeforeMethod()
@Parameters("browser")
public void launchBrowser(String browser) {
if(browser.equalsIgnoreCase("Chrome")) {
System.setProperty("webdriver.chrome.driver", "C:\\qtp\\chromedriver.exe");
driver = new ChromeDriver();
} else if(browser.equalsIgnoreCase("FF")){
driver = new FirefoxDriver();
} else {
driver = new InternetExplorerDriver();
}
}
 
@AfterMethod
public void closeBrowser() {
driver.close();
driver.quit();
}
 
}
 
@Test
public class WDtest extends TC{
 
public void wordpress() {
 
xml file 
 
<suite name="Wikipedia Test" verbose="3" parallel="tests">
<test name="Wiki in FF">
<parameter name="browser" value="FF"></parameter>
<classes>
<class name="com.selenium.WDtest" />
</classes>
</test>
</suite>
 
Error -
 
FAILED CONFIGURATION: @BeforeMethod launchBrowser
org.testng.TestNGException: 
Parameter 'browser' is required by @Configuration on method launchBrowser but has not been marked @Optional or defined
in C:\Documents and Settings\mashok\Local Settings\Temp\testng-eclipse--372384084\testng-customsuite.xml
 
 

1 Answer

0
Best answer
0

Try to define paramter at suite level and let me know your results.

 

<suite name="Wikipedia Test" verbose="3" parallel="tests">
<parameter name="browser" value="FF"></parameter>
<test name="Wiki in FF">
<classes>
<class name="com.selenium.WDtest" />
</classes>
</test>
</suite>
answered by
selected by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...