在IE11中尝试查找元素时,接收错误为'org.openqa.selenium.NoSuchWindowException:无法在关闭窗口中找到元素'

时间:2017-05-24 18:20:06

标签: internet-explorer selenium-webdriver

我正在尝试启动IE webdriver并找到所提供链接的任何元素。 同样的问题在Chrome和FF中运行良好,但抛出下面提到的错误。 我用谷歌搜索并更新了注册表文件以及所需的值但仍然出错。 更新了注册表详细信息: HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Internet Explorer \ Main \ FeatureControl \ FEATURE_BFCACHE

收到错误: org.openqa.selenium.NoSuchWindowException:无法在关闭的窗口中找到元素(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:30毫秒 构建信息:版本:'未知',修订版:'未知',时间:'未知' 系统信息:主机:'IBM298-PC0BYATM',ip:'192.168.0.6',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.8 .0_121' 驱动程序信息:org.openqa.selenium.ie.InternetExplorerDriver 功能[{se:ieOptions = {browserAttachTimeout = 0.0,ie.enableFullPageScreenshot = true,enablePersistentHover = true,ie.forceCreateProcessApi = false,ie.forceShellWindowsApi = false,ignoreZoomSetting = false,ie.fileUploadDialogTimeout = 3000.0,ie.useLegacyFileUploadDialogHandling = false, nativeEvents = true,ie.ensureCleanSession = false,elementScrollBehavior = 0.0,ie.browserCommandLineSwitches =,requireWindowFocus = false,initialBrowserUrl = http://localhost:36802/,ignoreProtectedModeSettings = false,enableElementCacheCleanup = true},browserName = internet explorer,pageLoadStrategy = normal,javascriptEnabled = true,version = 11,platform = WINDOWS,unexpectedAlertBehaviour = dismiss}] 会话ID:7fd5e21f-9930-4a06-9ec4-cd379a1930f3 ***元素信息:{Using = id,value = lst-ib}

代码段:

@Test
    public void GoogleSearch() throws Exception
    {
    UtilityLibrary.Instance.get("http://www.google.com");
    Thread.sleep(5000);
    UtilityLibrary.Instance.findElement(By.id("lst-ib")).sendKeys("TestNG Test");
    Thread.sleep(5000);
    }

实用程序代码段:

public class UtilityLibrary {

    public static WebDriver Instance = null;
    public static String Browser = "IE";

    public static void WebdriverInstance()
    {
        if (Browser.equalsIgnoreCase("Chrome"))
        {
            System.setProperty("webdriver.chrome.driver", "C:\\Users\\IBM_ADMIN\\Desktop\\Drivers\\chromedriver.exe");
            Instance= new ChromeDriver();
        }
        else if (Browser.equalsIgnoreCase("IE"))
        {
            //DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
            //caps.setCapability(
              //  InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
               // true);
            System.setProperty("webdriver.ie.driver", "C:\\Users\\IBM_ADMIN\\Desktop\\Drivers\\IEDriverServer.exe");            
            Instance= new InternetExplorerDriver();
        }
        Instance.manage().window().maximize();
        Instance.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

}

请建议是否需要更改更多配置。

0 个答案:

没有答案