我在 xml 文件中传递参数,系统仍将值作为 param-val-not-found
I am passing parametes in xml file still system is taking value as param-val-not-found
我正在使用参数注释,我已经在 Alltext.xmls 文件中传递了值,但是系统没有识别该值,而是将值作为 "param-value-not-found"。
Alltest.java class
public class AllTest {
@Parameters({ "username1", "password1" })
@Test(priority = 1, groups = { "PositiveTest", "smokeTests" })
public void positiveloginTest(String username1, String password1) throws InterruptedException {
System.out.println("Start login test");
System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe");
WebDriver driver = new ChromeDriver();
String url = "http://the-internet.herokuapp.com/login";
driver.get(url);
System.out.println("Page is opened");
// Locators
WebElement username2 = driver.findElement(By.id("username"));
username2.sendKeys(username1);
WebElement password2 = driver.findElement(By.id("password"));
password2.sendKeys(password1);
WebElement loginbutton = driver.findElement(By.className("radius"));
loginbutton.click();
}
Alltest.xml 文件
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="AllTest" verbose="1">
<test name="PositiveTest">
<parameter name="username1" value="tomsmith" />
<parameter name="password1" value="SuperSecretPassword!" />
<groups>
<run>
<include name="PositiveTests"></include>
</run>
</groups>
<classes>
<class name="com.herokuapp.theinternet.AllTest" />
</classes>
</test>
</suite>
群名中有typo
组名 PositiveTest
在测试注释中给出,而 PositiveTests
在 testng.xml 文件中使用。从 xml 文件
下的组名中删除多余的 s
我正在使用参数注释,我已经在 Alltext.xmls 文件中传递了值,但是系统没有识别该值,而是将值作为 "param-value-not-found"。
Alltest.java class
public class AllTest {
@Parameters({ "username1", "password1" })
@Test(priority = 1, groups = { "PositiveTest", "smokeTests" })
public void positiveloginTest(String username1, String password1) throws InterruptedException {
System.out.println("Start login test");
System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe");
WebDriver driver = new ChromeDriver();
String url = "http://the-internet.herokuapp.com/login";
driver.get(url);
System.out.println("Page is opened");
// Locators
WebElement username2 = driver.findElement(By.id("username"));
username2.sendKeys(username1);
WebElement password2 = driver.findElement(By.id("password"));
password2.sendKeys(password1);
WebElement loginbutton = driver.findElement(By.className("radius"));
loginbutton.click();
}
Alltest.xml 文件
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="AllTest" verbose="1">
<test name="PositiveTest">
<parameter name="username1" value="tomsmith" />
<parameter name="password1" value="SuperSecretPassword!" />
<groups>
<run>
<include name="PositiveTests"></include>
</run>
</groups>
<classes>
<class name="com.herokuapp.theinternet.AllTest" />
</classes>
</test>
</suite>
群名中有typo
组名 PositiveTest
在测试注释中给出,而 PositiveTests
在 testng.xml 文件中使用。从 xml 文件
s