没有这样的元素例外| IE浏览器 [英] No such element exception | Internet explorer

查看:175
本文介绍了没有这样的元素例外| IE浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

***使用相关的html代码更新了问题。

*** Updated the question with relevant html code.

我在尝试从下拉列表中选择任何值时遇到错误。

I'm facing error while trying to select any value from dropdown.

错误是


线程main中的异常org.openqa.selenium.NoSuchElementException:无法找到带css选择器的元素== #oHeight

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with css selector == #oHeight

我已经设置了 Selenium Docs <中提到的所有IE设置/ a>

I have already set all the IE settings as mentioned in Selenium Docs

我试过的代码如下所示:

The code i have tried is mentioned below:

System.setProperty("webdriver.ie.driver", "D:\\Workspace\\Selenium\\Model\\servers\\IEDriverServer_32bit.exe");
    WebDriver driver = new InternetExplorerDriver();
    driver.manage().timeouts().implicitlyWait(15000, TimeUnit.MILLISECONDS);
    driver.get("http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog2.htm");

    WebElement ddlHeight = driver.findElement(By.id("oHeight"));
    Select select = new Select(ddlHeight);
    select.selectByVisibleText("150");

    driver.findElement(By.xpath("//input[@value='Push To Create']")).click();

    driver.quit();

系统配置是Windows 7 + IE 11

The system config is Windows 7 + IE 11

推荐答案

你可以尝试这个代码,它正在我的系统上工作:
我正在使用IE 11 + Win7 Professional:

You can try this code , It's working on my System : I'm using IE 11 + Win7 Professional:

代码

public class Sandeep {

    static WebDriver driver;
    static WebDriverWait wait;

    public static void main(String[] args) throws InterruptedException {
         System.setProperty("webdriver.ie.driver", "D:\\Automation\\IEDriverServer.exe");
            InternetExplorerOptions options =  new InternetExplorerOptions();
            options.ignoreZoomSettings();
            driver = new InternetExplorerDriver(options);
            driver.manage().window().maximize();
            wait = new WebDriverWait(driver, 40);
            driver.get("http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog2.htm");
            wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("oHeight")));
            wait.until(ExpectedConditions.elementToBeClickable(By.id("oHeight")));
            Select select = new Select(driver.findElement(By.id("oHeight")));
            select.selectByVisibleText("150");
//          wait.until(ExpectedConditions.elementToBeClickable(By.name("Push To Create")));
//          driver.findElement(By.name("Push To Create")).click();
            driver.close();

        }

    }

请让我知道您是否有任何与此相关的问题。

Please let me know if you have any concerns related to this.

这篇关于没有这样的元素例外| IE浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆