1
我有以下的HTML頁面通過硒檢索從div嵌套值在C#
<div class="Test_cWidgetContainer" id="479b9c05-3f2b-43a1-c24d-89f574673326" draggable="false" style="background-repeat: no-repeat; background-position: center center; background-size: 100% 100%; background-color: rgb(255, 255, 255); position: absolute; left: 20px; top: 15px; width: 159px; height: 31px; z-index: 8; font-size: 0px;">
<div style="text-align: center; display: table; width: 100%; height: 100%;">
<div style="vertical-align: middle; display: table-cell;">
<div style="display: inline-block; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 9px; line-height: normal; font-family: TestDefault, Arial, sans-serif; color: rgb(70, 70, 70);">FIC636130682944873438 - 1</div>
</div>
</div>
</div>
我寫了下面的一段代碼來顯示文本輸出FIC636 ...
IWebElement element = driver.FindElement(By.ClassName("Test_cWidgetContainer"));
String labelText = element.Text
Console.WriteLine(labelText);
但在LabelText的不顯示任何價值?有人可以幫我解決代碼的問題。
謝謝,但我怎麼處理,如果我不知道DIV多少嵌套的生成此頁通過不同工具上的自定義控件。 –
是您的文字'FIC636130682944873438'總是與'FIC'或每個動態時間開始? – NarendraR
文本始終是動態的,因爲此文本來自底層數據庫,它可以有多個值。 –