这是我的HTML代码
<div id="sucessmessage" class="confirmmessage">
<img src="/QA_TEST/OURTEST/success.gif" alt="">
New Customer Successfully Created
</div>
我如何尝试获取&#34;新客户成功创建的文本值&#34;
String myxapth = "//*[@id='successMessage']/img";
String myvalue1 = driver.findElement(By.xpath(myxapth)).getText();
String myvalue2 = driver.findElement(By.xpath(myxapth)).getAttribute("value") ;
系统结果如下 myvalue1为null myvalue2为空
答案 0 :(得分:0)
尝试使用以下代码,
String text=driver.findElement(By.Id("successMessage").getText();
System.out.println("text value is" + text);
答案 1 :(得分:0)
尝试以下xpath -
String myxapth = "//*[@id="sucessmessage"]";
String myvalue1 = driver.findElement(By.xpath(myxapth)).getText();