我用TestNG類創(chuàng)建了一個(gè)Maven項(xiàng)目。在TestNG.xml中,我給出了套件名稱。我使用多個(gè)瀏覽器Chrome和Firefox來并行運(yùn)行。只是使用安裝類和另外一個(gè)類它工作正常但是當(dāng)我包含多個(gè)帶@Test注釋的類時(shí),我將得到一個(gè)注入錯(cuò)誤并將給出錯(cuò)誤。我將提供我嘗試過的代碼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
@Testpublic static void valid_logintest ()throws MalformedURLException, InterruptedException {
}@Test
public static void valid_test ()throws MalformedURLException, InterruptedException {
}我收到的錯(cuò)誤是:無(wú)法使用[class org.openqa.selenium.remote.DesiredCapabilities]注入@Test帶注釋的方法[valid_test]。期望運(yùn)行兩個(gè)測(cè)試用例valid_logintest和valid_test
2 回答

搖曳的薔薇
TA貢獻(xiàn)1793條經(jīng)驗(yàn) 獲得超6個(gè)贊
很可能你在項(xiàng)目的某處有一個(gè)函數(shù),它看起來像:
@Testpublic void sometest(DesiredCapabilities caps) { }
這不是參數(shù)化TestNG測(cè)試方法的正確方法,你應(yīng)該從@Test注釋的方法中刪除這個(gè)DesiredCapabilities參數(shù)
如果要將外部參數(shù)傳遞給與@Test
您一起注釋的方法,則應(yīng)使用@Parameters
注釋
添加回答
舉報(bào)
0/150
提交
取消