2016-08-05 26 views
-5

HTML代碼,獲取從網絡元素文本我如何使用C#

<span id="lbl_OrderNum" class="ff1 fs12 fwb " style="font-size:18px;">  eSYS9778</span> 

C#代碼

driver.FindElementById("lbl_OrderNum").GetAttribute("textContent"); 
Console.WriteLine("textContent"); 

我如何使用獲取的文本或獲得屬性的文本保存在我的硒代碼?

+1

請問你嘗試過什麼了嗎? – Xiaoy312

+0

driver.FindElementById(「lbl_OrderNum」)。GetAttribute(「textContent」); Console.WriteLine(「textContent」); – sunizzil

+0

'driver.FindElementById'返回的元素應該具有'Text'屬性。 – Xiaoy312

回答

0

我注意到的textContent只適用於Firefox,如果你使用的是Chrome或IE瀏覽器,你將需要使用

GetAttribute("innerText")