An exception of type 'System.InvalidOperationException' occurred in WebDriver.dll
but was not handled in user code
Additional information: JavaScript error (UnexpectedJavaScriptError)
I'm trying to browse a url using IE.
I get this error only for Internet explorer. For chrome & firefox it works fine.
Using IE 11, IEDriverServer_Win32_2.47.0, Windows 7 64-bit
C#:
[TestMethod]
public void GeneratePageSnaps()
{
IWebDriver NewDriver;
NewDriver = new InternetExplorerDriver("D:\IeDriver");
NewDriver.Navigate().GoToUrl("http://www.google.com");
NewDriver.Manage().Window.Maximize();
IWait<IWebDriver> wait = new WebDriverWait(NewDriver, TimeSpan.FromSeconds(10.00));
wait.Until(driver1 => ((IJavaScriptExecutor)NewDriver).ExecuteScript(
"return document.readyState").Equals("complete")); //error here
}
You must read the document before using it :
The InternetExplorerDriver is a standalone server which implements WebDriver's wire protocol. This driver has been tested with IE 6, 7, 8, 9, and 10 on appropriate combinations of XP, Vista and Windows 7.
The driver supports running 32-bit and 64-bit versions of the browser. The choice of how to determine which "bit-ness" to use in launching the browser depends on which version of the IEDriverServer.exe is launched. If the 32-bit version of IEDriverServer.exe is launched, the 32-bit version of IE will be launched. Similarly, if the 64-bit version of IEDriverServer.exe is launched, the 64-bit version of IE will be launched.
Read More ...
And this one is for you :
For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.
For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.
Try resetting your IE browser settings.It worked for me, just go to the
settings>Internet Options>Advanced>Reset
Just reset and restart the system.
NOTE:
For Selenium web driver to work with IE the following should also need to be done :
Internet Options>Security, Select "Enable protected mode" for all the 4 options then Apply these changes and then restart the systems..then only it works.
Related
C# Browser version get wrong version for windows 11(last windows update v:11.187.14393.0)
HttpBrowserCapabilities browser = Request.Browser;
Console.WriteLine("Result:" + browser.MajorVersion.ToString());
Result:7
Go into Internet Explorer and hit F12. Check the emulation tab.
Document Mode and User Agent string are what determine the browser version.
change both those settings to
Document Mode: Edge (default)
User Agent String: Default
I'm using the C# bindings for Selenium and trying to get a simple automated test in Microsoft Edge working.
class Program
{
static void Main(string[] args)
{
EdgeOptions options = new EdgeOptions();
options.PageLoadStrategy = EdgePageLoadStrategy.Eager;
RemoteWebDriver driver = new EdgeDriver();
driver.Url = "http://bing.com/";
}
}
But the program halts on the initialisation of the EdgeDriver, the edge browser launches but the url never changes to "bing.com".
Has anyone else experienced this?
I have faced the same issue. I followed the below steps to resolve it :-
Download the correct Microsoft WebDriver server version for your build.
How to find your correct build number :-
1- Go to Start > Settings > System > About and locate the number next to OS Build on the screen. This is your build number. Having the correct version of WebDriver for your build ensures it runs correctly.
2- Run this command systeminfo | findstr /B /C:"OS Version" this will give the output like OS Version: 10.0.10586 N/A Build 10586. Here is build number is 10586
You need to check your Windows OS build number and download appropriate .msi and install it.
Provide the Syetem property where MicrosoftWebDriver.exe installed to webdriver.edge.driver.
Note :- The Default installed location of the MicrosoftWebDriver.exe :-
for 64 bit is C:\Program Files (x86)\Microsoft Web Driver
for 32 bit is C:\Program Files\Microsoft Web Driver
Hope it will work...:)
This happens when your system does not match the webdriver version... Determine which release of Windows 10 you are using... then go here and download same release..
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver
Here's what the error looks like when the versions don't match.
Selenium will Hang
EdgeOptions options = new EdgeOptions();
options.PageLoadStrategy = EdgePageLoadStrategy.Eager;
RemoteWebDriver driver = new EdgeDriver();
driver.Url = "http://bing.com/";
Results in this exception with Edge still up and on the Bing page
Exception Thrown
changing the code to this, with no options:
var driver = new EdgeDriver();
driver.Url = "http://bing.com/";
Results in this:
Exception thrown: 'System.InvalidOperationException' in WebDriver.dll
And this in the console.
Something's not right with the MicrosoftWebDriver.Exe which was downloaded from here. https://www.microsoft.com/en-us/download/details.aspx?id=48212 and installed into the Program Files folder by default. Here's screenshot of add/remove programs. System is Windows 10 PRO 64 bit.
Note I did not try the 32 bit version
I have a VB6 EXE which I want to trigger through C# code as shown below. After this code execution, I can see the EXE has been started in taskmanager, and got finished after sometime.
I deploy the code in IIS Server. Start Browsing the site and click on the button of c# code which starts the VB6SOME.exe. The Exe started but never got completed (Taskmanager is showing the VB6SOME.exe for user NETWORK Service).
prcstrinfo.FileName = "VB6SOME.exe";
prcstrinfo.Arguments = "USERID,PASSWORD," + DateTime.Now.ToShortDateString();
Process proc = Process.Start(prcstrinfo);
Also, I tried to call the VB6SOME.exe through CMD passing all necessary arguments. It got started and finished correctly. (I also monitored the TaskManager and I saw that it started as MY ID not as Network Service). Please help to fix the issue.
Registry Redirector
The registry redirector isolates 32-bit and 64-bit applications by providing separate logical views of key portions of the registry on WOW64. The registry redirector intercepts 32-bit registry calls to each logical registry view and maps them to the corresponding physical registry location. The redirection process is transparent to the application. Therefore, a 32-bit application can access registry data as if it were running on 32-bit Windows even if the data is stored in a different location on 64-bit Windows.
Redirection is enabled for the following registry keys:
HKEY_LOCAL_MACHINE\Software
From Windows SDK 64 Bit Development Guide
Using Selenium Grid2 and RemoteWebDriver in an MSTest class, I am struggling to get OperaDriver working.
I create the Selenium hub and Opera node by running the following commands in CMD:
start java -jar selenium-server-standalone-2.30.0.jar -role hub
start java -jar selenium-server-standalone-2.30.0.jar -role node -port 7001 -browser "browserName=opera,version=11.62,maxInstances=5,platform=WINDOWS" -hub http://localhost:4444/grid/register
And this works fine, I can the see the registered node when I view my hub in a browser.
But I get an exception whenever I try to create a new WebDriver in my C# test class:
DesiredCapabilities operaCapabilities = DesiredCapabilities.Opera();
operaCapabilities.SetCapability(CapabilityType.BrowserName, "opera");
operaCapabilities.SetCapability(CapabilityType.Platform, "WINDOWS");
operaCapabilities.SetCapability(CapabilityType.Version, "11.62");
operaCapabilities.SetCapability("opera.binary", "C:\\Program Files\\Opera\\opera.exe");
operaCapabilities.SetCapability("opera.port", 7001);
RemoteWebDriver operaDriver = new RemoteWebDriver(operaCapabilities);
Actually I get two different exceptions - the first time after creating the hub and node in Selenium I get this:
Could not find a platform that supports bundled launchers, please set
it manually
Build info: version: '2.30.0', revision: 'dc1ef9c', time: '2013-02-19
00:15:27'
System info: os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2',
java.version: '1.7.0_15'
Driver info: driver.version: OperaDriver
And everytime after that I get the following error:
Could not initialize class
com.opera.core.systems.runner.launcher.OperaLauncherRunner
I am using Selenium-standalone-2.30.0.
I was using Opera version 12.14 but downgraded to 11.62 after I saw a list of compatible versions on the OperaDriver wiki page but the errors remain the same.
I have tried initialising the RemoteWebDriver with and without the capabilities above and get the same result every time.
Does anyone know what the problem is here and how to get a RemoteWebDriver working with Opera in this way?
Edit: Could it be that the platform for Opera version 12.14 reads as 'WINDOWS 8', and version 11.62 reads as "WIN32" when I open the Opera browser and view Help => About? As I am specifying the platform as WINDOWS in the node and RemoteWebDriver. If I try to specify WINDOWS 8 as the platform for the RemoteWebDriver an new exception is thrown where it can't find matching enum:
org.openqa.selenium.WebDriverException:
java.lang.IllegalArgumentException: No enum constant
org.openqa.selenium.Platform.WINDOWS 8
Edit2: For some reason CurrentPlatform is returning Vista for me, even though I am running Windows8.
Platform platform = Platform.CurrentPlatform;
And I also noticed that the OperaDriver source code checks for 'VISTA' in uppercase whereas the Platform in C# reads as 'Vista'.
Could this be causing the problem?
I've been suffering from this problem as well and thanks to the hint from eviltester I was able to solve the issue by using the following command line to start the selenium server:
java -Dos.name=windows -jar selenium-server-standalone-2.32.0.jar
The use of -Dos.name=windows is the equivalent of System.setProperty("os.name", "windows") and will allow your C# selenium code to work for the Opera browser.
I saw this when running in Java. In debug mode it looked like a possible omission in OperaLauncherRunner.java launcherNameForOS does not cater for the WIN8 enum returned by Platform.getCurrent().
In Java I fudged it by setting the system property "os.name" to "windows" before creating a new OperaDriver. This forced the Platform.getCurrent to return XP which the opera launcher was happy with.
So in java I just used this hack:
System.setProperty("os.name","windows");
driver = new OperaDriver();
Why does the following problem happen?
Scenario:
Make sure that IIS is installed
Execute "notepad
%WINDIR%\System32\inetsrv\config\applicationHost.config" using admin
account
Actual Result: the file is successfully opened in notepad
Execute the following code in admin account's context:
string filePath = #"%WINDIR%\System32\inetsrv\config\applicationHost.config";
Console.WriteLine(File.Exists(Environment.ExpandEnvironmentVariables(filePath)));
Actual Result: False
Expected Result: True
The problem is if you are running a 32-bit application on a 64-bit OS, the .Net framework automatically redirects the request from %WINDIR%\System32 to %WINDIR%\SysWOW64.
If you change your project to target 64-bit, this will solve your problem.
You can also resolve the problem by changing System32 to sysnative, but only if you leave the application as a 32-bit app:
string filePath = #"%WINDIR%\sysnative\inetsrv\config\applicationHost.config";
This might be due to file system redirection. AFAIK t happens either for 32/64 bit mismatch or in case of low-privilege (UAC) processes.
I know of now way of disabling that behavior using managed APIs. You need to use http://msdn.microsoft.com/en-us/library/windows/desktop/aa365743(v=vs.85).aspx and/or be a high privilege process.
If you change your project to target 64-bit, this is likely to solve your problem.
I can't reproduce your result. When I run this from an administrator command line prompt, I get exists = True.
string s = #"%WINDIR%/System32\inetsrv\config\applicationHost.config";
bool exists = File.Exists(Environment.ExpandEnvironmentVariables(s));
Console.WriteLine("exists = {0}", exists);
I'm running Windows Server 2008, 64-bit. .NET 4.0.