簡體   English   中英

通過C#處理Selenium Webdriver中動態生成的元素

[英]Handling dynamically generated elements in selenium webdriver via C#

我正在嘗試自動測試包含項目列表的網頁。

這是帶有擴展元素的Google雲端硬盤中的“創建”按鈕。 我已經使用XPath定位器來找到按鈕“ Create”( driver.FindElement(By.XPath("")) ,但是我不知道如何使用C#和webdriver訪問擴展元素並單擊它們。

這是下面的代碼。 請幫幫我。

 `<div tabindex="0" class="j-Ta-pb f-e f-e-dg a-Da-e" role="button" aria-label="Создать" style="-moz-user-select: none;" guidedhelpid="new_menu_button" aria-expanded="false" aria-haspopup="true">
<div class="j-Ta-pb f-e-og-aa">
<div class="j-Ta-pb f-e-qb-aa">
<div class="j-Ta-pb f-e-rf" aria-hidden="true">Создать</div>
<div class="j-Ta-pb f-e-Tc">&nbsp;</div></div></div></div>`

您應該基於靜態部分。 假設j-Ta-pb始終是靜態/不變的,則可以使用此xpath

//div[contains(@class, 'j-Ta-pb')]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM