Reputation: 23
I have created a Maven Project with TestNG classes. In TestNG.xml I have given the suite name . I have used multiple browsers Chrome and Firefox to run parallel. Just with setup class and one more class it works fine but when I include multiple classes with @Test
annotation I will get an inject error and will gives an error.
I will provide the code which i have tried
Setup.java
if (browser.equals("Firefox")) {
/*the path of the gecko driver is set*/
System.setProperty("firefoxpath");
drfirefox=DesiredCapabilities.firefox();
drfirefox.setBrowserName("firefox");
drfirefox.setPlatform(Platform.WINDOWS);
} else {
/*the path of the chrome driver is set*/
System.setProperty("chrome path");
drchrome=DesiredCapabilities.chrome();
drchrome.setBrowserName("chrome");
drchrome.setPlatform(Platform.WINDOWS);
}
logintest_valid.java
@Test
public static void valid_logintest ()throws MalformedURLException, InterruptedException {
}
@Test
public static void valid_test ()throws MalformedURLException, InterruptedException {
}
I am getting error as:
Cannot inject @Test annotated Method [valid_test] with [class org.openqa.selenium.remote.DesiredCapabilities].
Expect to run both test cases valid_logintest and valid_test
Upvotes: 1
Views: 170
Reputation: 168197
Most probably you have a function somewhere in your project which looks like:
@Test
public void sometest(DesiredCapabilities caps) {
}
This is not correct way of parameterising TestNG test methods, you should remove this DesiredCapabilities argument from the method annotated with @Test
If you want to pass an external argument to the method annotated with @Test
you should be using @Parameters
annotation
Upvotes: 0