我想检查文本字段值是否与我在代码中提到的预期值相同
这是我需要值的文本字段
输入类型="text" value="sadas" class="mdl-textfield__input" id="last_name" name="last_name" placeholder="输入姓氏"
我得到的错误,
TestNG 错误消息显示如下, java.lang.AssertionError: expected [6234] but found [] and nothing print for the console
我试过“Assert.assertTrue(lastName.equals("lastName : 6234"));” 也
@Test
public void tc001() {
driver.get(baseUrl);
driver.findElement(By.xpath("//input[@name='email']")).click();
driver.findElement(By.xpath("//input[@name='email']")).clear(); driver.findElement(By.xpath("//input[@name='email']")).sendKeys("x@gmail.com");
driver.findElement(By.xpath("//input[@name='password']")).clear();driver.findElement(By.xpath("//input[@name='password']")).sendKeys("123456");
driver.findElement(By.xpath("(.//*[normalize-space(text()) and normalize-space(.)='Forgot Your Password?']) [1]/preceding::button[1]")).click();
driver.findElement(By.linkText("Nadee")).click();
driver.findElement(By.linkText("Profile")).click();
String lastName = driver.findElement(By.xpath("//input[@name='last_name']")).getText();
Assert.assertEquals(lastName ,"6234");
System.out.println(lastName);
driver.findElement(By.linkText("Log Out")).click();
}
我怎样才能解决这个问题?以及为什么当预期值与找到的值相同时出现此错误?(手动检查系统时)