簡體   English   中英

如何在 C# 中使用 Selenium 發送帶有 aria-hidden="true" 的元素的鍵

[英]How to Sendkeys on an element with aria-hidden=“true” using Selenium in c#

我有如下代碼

第一部分代碼

第二部分代碼

我嘗試代碼

 driver.FindElement(By.XPath("//*[@id='idms-input-labelledby-1601454890596-1']")).SendKeys("");

但是我發現有一個錯誤,因為id每次都在變化

很感謝

id 確實在不斷變化,但您必須找到保持不變的內容...

你的回答大概是:

driver.FindElement(By.XPath("//div[@class='form-element']/input[contains(@class,'generic-input-field   form-textbox form-textbox-text')]")).SendKeys("urfirstname");

我試過這個,它的工作原理。

您可以通過訪問它們的索引來獲取它們並發送密鑰。

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
List<WebElement> elements = wait.until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//idms-error-wrapper/div/div/input")));
elements.get(0).SendKeys("");

暫無
暫無

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

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