driver.get("https://www.baidu.com/");
System.out.println(driver.findElement(By.xpath("//input[@id='su' and @type='submit']")).getAttribute("value"));
Assert.assertTrue(driver.findElement(By.xpath("//input[@id='su' and @type='submit']")).getAttribute("value").equals("百度一下"));
但是放到Ant中,就异常了。郁闷。
代码基本是一样的。
@Test
public void GetLinkText(){
driver.get("https://www.baidu.com/");
System.out.println(driver.findElement(By.xpath("//input[@id='su' and @type='submit']")).getAttribute("value"));
Assert.assertTrue(driver.findElement(By.xpath("//input[@id='su' and @type='submit']")).getAttribute("value").equals("百度一下"));
}
testng配置xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
[testng] FAILED: GetLinkText
[testng] java.lang.AssertionError
[testng] at org.junit.Assert.fail(Assert.java:86)
[testng] at org.junit.Assert.assertTrue(Assert.java:41)
[testng] at org.junit.Assert.assertTrue(Assert.java:52)
[testng] at com.test.Units.ChineseTest.GetLinkText(ChineseTest.java:34) 《==这里是上面的Assert地方