如何用java处理SeleniumWebDriver中隐藏的webelement
我的Html如何用java处理SeleniumWebDriver中隐藏的webelement,java,selenium,Java,Selenium,我的Html 请选择 阿富汗 阿尔巴尼亚 我想从下拉列表中选择值,我已经使用了选择方法,但它不起作用。获取: 元素未找到异常 不确定如何处理此不可见的元素。有什么帮助吗 实际上select元素在提供的HTML中看到的iframe中,因此在查找select元素之前,您需要先切换该iframe,如下所示:- driver.switchTo().frame(driver.findElement(By.cssSelector("iframe.demo-frame"))); //Now find t
请选择
阿富汗
阿尔巴尼亚
我想从下拉列表中选择值,我已经使用了选择方法,但它不起作用。获取:
元素未找到异常
不确定如何处理此不可见的元素。有什么帮助吗 实际上
select
元素在提供的HTML中看到的iframe
中,因此在查找select
元素之前,您需要先切换该iframe
,如下所示:-
driver.switchTo().frame(driver.findElement(By.cssSelector("iframe.demo-frame")));
//Now find the dropdown
Select select = new Select(driver.findElement(By.tagName("select"));
select.selectByVisibleText("Afghanistan");
您是否考虑过select元素位于iframe中并切换到iframe的事实。是的,我尝试了此操作,但在driver.switchTo().frame(0)中卡住了;Select sel=new Select(driver.findElement(arg0)),因为没有定位符来定位此参数。您要传递的arg0是什么?尝试使用.tagName(“选择”)搜索。