问题
May be this question has been asked many times before. But i went through all the related questions in stackoverflow , but couldn't find any satisfactory solution.
Well i'am writing a selenium automation code in VS2010 using C#, IE11 is my web browser on which i'am performing testing. Using IEDriverServer 32bit version in Windows 7 to open IE instance.
I already knew that there is some compatibility kind of issue between selenium and IE 11, but still my code worked fine up till now when i started getting this Error - " NoSuchWindowException was unhandled : Unable to find element on closed window."
Below are my steps:-
IWebDriver driver = new InternetExplorerDriver("D:\\");
driver.Navigate().GoToUrl("http://aiaw00572.belldev.dev.bce.ca:8060/UTM_MechHDTool_UserWebApp");
driver.FindElement(By.Id("ctl00_cpMainContent_radcboTaskType_Input"), 10).Click();
driver.FindElement(By.XPath("//div[@id='ctl00_cpMainContent_radcboTaskType_DropDown']/div/ul/li[2]")).Click(); (this step select a drop down option which performs a postback on the page)
driver.FindElement(By.Id("ctl00_cpMainContent_utmTaskGrid_ctl00_ctl06_imgbtnStartWorking")).Click();//Getting error on this step. Earlier i was not getting it anywhere
I searched for the solutions for this problem and came to know about one solution in which some registry change has to be done to solve it, though that also does not confirm that it will solve the problem. But the problem here i can't even check this solution as i don't have any administrator privilege in my system.
So just wanted to know if someone else has also faced the problem and came with some solution, so he/she can share it here please as i badly need a solution in here for this situation.
回答1:
Worked for me after running IEDriverServer as admin or setting protected mode for all zones (https://stackoverflow.com/a/21373224/217408)
回答2:
Error:
org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window (WARNING: The server did not provide any stacktrace information)
Step1. Change Windows registry. If you use Internet Explorer 11 x64 (64 bit), create file ie11_win64.reg has content:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BFCACHE]
"iexplore.exe"=dword:00000000
Then run it.
If you use Internet Explorer 11 x86 (32 bit), create file ie11_win32.reg has content:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BFCACHE]
"iexplore.exe"=dword:00000000
Then run it.
Step2. Setting in internet explorer. Uncheck all (or Check all, must be the same for zones: Internet, Local intranet, Trusted sites, Restricted sites)
回答3:
For me the aswear was to download this registry file from http://heliumhq.com/docs/internet_explorer and to run it
回答4:
In our case tests were based on Jbehave and Serenity. The First test always pass and second fails with mentioned exception. Opening new Webdriver instance for each scenario helps to resolve issue.
来源:https://stackoverflow.com/questions/26712417/nosuchwindowexception-was-unhandled-unable-to-find-element-on-closed-window-i