我正在尝试从下拉菜单中选择该选项。但它没有被选中。测试用例通过时没有任何错误,也没有选择选项。因为它是html下拉列表,所以我使用了单击。我试着选了一门课,但没用。网站是https://demoqa.com/automation-practice-form/ 我在这里写的代码是
> JavascriptExecutor js=(JavascriptExecutor)driver;
> Actions act=new Actions(driver);
> js.executeScript("window.scrollBy(0,500)");
> WebElement we=driver.findElement(By.xpath("//div[@id='state']"));
> act.moveToElement(we).click().build().perform();
> WebElement we3=driver.findElement(By.xpath("//div[contains(.,'Uttar
> Pradesh')]/following-sibling::div/descendant::input"));
act.moveToElement(we3).click(we3).build().perform();
我们请求你的帮助。谢谢
2条答案
按热度按时间ruyhziif1#
它的不同元素你需要点击后,发送键为“北方邦”
使用以下代码
xoshrz7s2#
下面的代码对我有用。