-1
<ul id="name" class="abc">
<li class="def">
<a class="ghi">
<i style="background-color: transparent;">Welcome {{username}} </i>
</a>
</li>
</ul>
硒IDE給文本:
storeText //ul[@id="name"]/li/a/i a
echo ${a}
文本 「歡迎{{用戶名}」 正確顯示。
但是,在Selenium WebDriver中,我無法獲取文本。
driver.findElement(By.xpath("//ul[@id='name']/li/a/i")).getText();
上面的代碼行返回一個空值。
看到這個http://stackoverflow.com/questions/18637032/get-text-from-xpath-located-element-using-selenium-webdriver-with-javascript –
WebElement.getText()不適合我。我正在使用Chrome瀏覽器。不過,我可以在Firefox瀏覽器中使用Selenium IDE獲取文本。 – Lawrence
分享'Html'不是'圖像'。 –