用Selenium C自动完成AutoCompleteExtender#
问题描述:
我正在尝试自动完成一个自动完成的字段。 我使用了大量的Thread.Sleep来解决这个问题,但最好的情况是缓慢而温和的。用Selenium C自动完成AutoCompleteExtender#
我发现这的这段代码几次,它看起来像它会做的伎俩
driver.findElement(By.id("your searchBox")).sendKeys("your partial keyword");
Thread.sleep(3000);
List <WebElement> listItems = driver.findElements(By.xpath("your list item locator"));
listItems.get(0).click();
driver.findElement(By.id("your searchButton")).click();
不过我打一个问题与listItems.Get
那里我得到了以下信息
'List<IWebElement>' does not contain a definition for 'Get' and no extension method 'Get' accepting a first argument of type 'List<IWebElement>' could be found (are you missing a using directive or an assembly reference?)
我已经做了谷歌的一些狩猎和不能看到,如果我缺少一个DLL,或者如果get
已被替换,所以我一直无法得到这个工作
答
尝试listItems.ElementAt (0)
。您可能需要添加using System.Linq
这是完美的谢谢! – Smithy7876
很高兴能有帮助:) – iamkenos