Quality Testing

Quality is delighting customers

org.testng.TestNGException: Can inject only one of <ITestContext, XmlTest> into a @BeforeTest

BrowserSelection

public class BrowserSelection
{
    public static WebDriver driver;

   @Parameters("Browser")
   public static WebDriver ChooseBrowser(String browser)
   {
   if (browser.equalsIgnoreCase("Chrome"))
   {
   System.setProperty("webdriver.chrome.driver", "D:\\Softwares\\chromedriver_win32\\chromedriver.exe");
  driver = new ChromeDriver();
  driver.manage().window().maximize();
  driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
  }
  else if(browser.equalsIgnoreCase("Firefox"))
  {
  System.setProperty("webdriver.gecko.driver", "D:\\Softwares\\geckodriver-v0.23.0-win64\\geckodriver.exe");
  driver = new FirefoxDriver();
  driver.manage().window().maximize();
 driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}

return driver;

}

}

QT Class:

public class QT

{

 WebDriver driver;

 @BeforeTest

  public void OpenBrowser(String browser)

  {

  driver = BrowserSelection.ChooseBrowser(browser);

  }

 @AfterTest public void CloseBrowser()

  {

    driver.quit(); }

   } 

}

While running QT Class, throwing " org.testng.TestNGException:
Can inject only one of <ITestContext, XmlTest> into a @BeforeTest " exception. Can anyone help me please.

Views: 94

Reply to This

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service