简体   繁体   中英

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

I have code as below

part one code

part two code

i try code

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

But I discovered that there is a mistake because the id changes every time

very thanks

The id is really kept changing but you have to find what remains the same...

Your answer is probably:

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

I tried this and it works.

You could grab them all and send keys by accessing their indexes.

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("");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM