我在日志文件中没有得到任何错误来解决该问题。该代码将输入到homepage.java中,并以login方法开头,但是txtusername不会填充这些值。在日食中工作正常。从命令行执行时会发生这种情况
D:\Workspaces\test> java -cp
"D:\Workspaces\test\bin;D:\Workspaces\test\lib\*;C:\Users\me\plugins\*"
org.testng.TestNG D:\Workspaces\test\testng1.xml
public class TestMain extends DriverInstance {
HomePage homePage;
WebDriver driver;
@BeforeMethod
public void launchAppication() {
driver = launchBrowser();
launchURL();
homePage = PageFactory.initElements(driver, HomePage.class);
}
@Test(groups = { "functest", "Login" }, testName = "RTSFS-21: Verify Login with Correct username and correct Password", priority = 1)
public void verifyLogin_CorrectLoginCredentials() {
try {
System.out.println("hello this is test method after try block");
//Thread.sleep(5000);
homePage.login(driver, "Login");
System.out.println("hello this is test method after login method");
// homePage.pageWait();
//Thread.sleep(5000);
homePage.validateURL("www.xyz.com", "Verify Login with Correct username and correct Password");
} catch (Exception e) {
log.fail("exception : " + e.getMessage());
}
}
}
这是homepage.java
public void login(WebDriver driver, String elementName)
{
JsonReader jr = new JsonReader();
try
{
System.out.println("hello this is login block");
txtUsername.sendKeys(jr.GetElementValue(elementName+".Username"));
System.out.println("hello this is text username");
}
执行将显示消息“您好,这是登录阻止”,并突然结束。