Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
205 views
in Selenium by Contributing Tester (32 points)
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 like 0 dislike
by
selected by
 
Best answer

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>


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...