简体   繁体   English

如何在 C# 中使用 Selenium 发送带有 aria-hidden="true" 的元素的键

[英]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但是我发现有一个错误,因为id每次都在变化

very thanks很感谢

The id is really kept changing but you have to find what remains the same... id 确实在不断变化,但您必须找到保持不变的内容...

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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