2

My Code is

@BeforeTest @Parameters("browser") public void browserinitialization(String browser) throws Exception { if(browser.equalsIgnoreCase("ie")) { System.setProperty("webdriver.ie.driver", "D:\\ESCLIPSE\\TestNG_project\\lib\\IEDriverServer.exe"); DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); driver = new InternetExplorerDriver(caps); } else if(browser.equalsIgnoreCase("chrome")) { System.setProperty("webdriver.ie.driver", "D:\\ESCLIPSE\\TestNG_project\\lib\\chromedriver.exe"); DesiredCapabilities caps = DesiredCapabilities.chrome(); driver = new InternetExplorerDriver(caps); } else { throw new Exception("Browser is not correct"); } driver.get(url); } @Test public void login() throws InterruptedException { driver.findElement(By.id("txtUserName")).sendKeys("name"); driver.findElement(By.id("txtPassword")).sendKeys("password"); driver.findElement(By.id("btnOk")).click(); Thread.sleep(5000); } @AfterTest public void quit() { driver.quit(); } 

My XML file is

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="TestSuite" thread-count="2" parallel="tests" > <test name="ChromeTest"> <parameter name="browser" value="Chrome" /> <classes> <class name="firstreport.Firsttryfor"> </class> </classes> </test> <test name="IETest"> <parameter name="browser" value="IE" /> <classes> <class name="firstreport.Firsttryfor"> </class> </classes> </test> 

I got the error as :

FAILED CONFIGURATION: @BeforeTest browserinitialization org.testng.TestNGException: Parameter 'browser' is required by @Configuration on method browserinitialization but has not been marked @Optional or defined in C:\Users\arunkumars\AppData\Local\Temp\testng-eclipse--441013644\testng-customsuite.xml at org.testng.internal.Parameters.createParameters(Parameters.java:155) at org.testng.internal.Parameters.createParameters(Parameters.java:358) at org.testng.internal.Parameters.createConfigurationParameters(Parameters.java:86) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:199) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) at org.testng.TestRunner.beforeRun(TestRunner.java:641) at org.testng.TestRunner.run(TestRunner.java:609) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) at org.testng.TestNG.run(TestNG.java:1057) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) SKIPPED CONFIGURATION: @AfterTest quit SKIPPED: login =============================================== Default test Tests run: 1, Failures: 0, Skips: 1 Configuration Failures: 1, Skips: 1 =============================================== 

Kindly help me out this.I am new to Java coding.Thanks in Advance

2
  • Check you have placed the xml file in correct location. This error will occur when you dont have the xml file Commented Sep 8, 2014 at 12:13
  • Thanks for the reply Vignesh. I have added the xml in my project.if it is wrong,where should I add the XML file? Commented Sep 8, 2014 at 12:15

1 Answer 1

2

Make sure you have the XML file in the correct path. If you're using eclipse, you should see the xml file along with the class files.

You haven't closed the suite </suite>

And also, are you trying to run the class firstreport.Firsttryfor instead of your XML file? If so you ll get that error.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.