"Unknown command received" errors using MicrosoftWebDriver and Selenium (C#) - c#

I am using Selenium (v2.47) and the Microsoft Web Driver (v10.0.10240.0). I am working with some existing C# code that already runs fine on Firefox, IE and Chrome and I want to use it to test the new Edge browser on Windows 10. My code is able to successfully open the browser and navigate to my login page. However I get an "Unknown command received" exception when I do a few basic things such as:
1) maximize the browser
2) call .FindElement(by) on an existing IWebElement.
For example:
driver.Manage().Window.Maximize(); //throws exception
...
IWebElement parent = driver.FindElement(By.TagName("body")); //works
...
parent.FindElement(by); //throws exception
Has anyone seen either of these work with Selenium and C# for the Edge browser? Maybe I am doing something wrong here. Or does "Unknown command received" just mean it is unimplemented functionality that will come in the future?

There was a fair amount of missing functionality in the initial (10.0.10240) Edge driver release, including missing support for IWebElement.FindElement(). Subsequent releases, which also required an update to Edge itself via Windows 10 updates, and until very recently only available via so-called Insider builds. A full accounting of what was implemented and when is provided by Microsoft at their WebDriver implementation status page.

Related

Selenium 4 Edge/Chrome Webdriver not working in C#

I have Edge version 107.0.1418.26 and Egde web driver version 107.0.1418.26 (chrome also has the correct versions). Selenium webdriver 4.5.1.
I had everything working a few weeks ago using chrome, I have revisited the project recently and everything has stopped working (reason for also trying Edge).
To restart at the basics I'm using the Microsoft example https://learn.microsoft.com/en-us/microsoft-edge/webdriver-chromium/?tabs=c-sharp and Selenium https://www.selenium.dev/documentation/
When I run:
var driver = new EdgeDriver();
try
{
driver.Url = "https://bing.com";
...
The webdriver console opens and initially says 'started successfully' but the c# code times out on the first line stating 'cannot start the driver service on http://localhost:55553'. I get a little more information with the Chrome test.
DevTools listening on ws://127.0.0.1:54097/devtools/browser/8e320eae-3f01-4ae2-9944-414ca8ad36e1
[23128:31564:1101/105231.394:ERROR:device_event_log_impl.cc(215)] [10:52:31.393] Bluetooth: bluetooth_adapter_winrt.cc:1074 Getting Default Adapter failed.
I don't know why it is trying bluetooth!
Initially I thought the problem to be a security issue over a remote desktop connection but I'm now in the office with the same issue. Something is niggling towards security but I can't find any further information or logs.
********** UPDATE *********
After vs2022 update, Java update and 4 reboots it now works again.
Can anyone come up with any reasons why it would just stop and cause the above problems? (the drivers were not left running in background). I'm very nervous to continue if I can't understand why errors are caused.
No true answer, however complete reboot (cold restart) then ensuring everythign os on the latest version worksfollowed by another reboot works evey time.

IE Windows Security dialog appears to block Selenium navigation

I am using Selenium in C# on Windows 10. The site under test should challenge with a Windows Security login box in IE, which it does. But the login box appears to block the call.
var home = "https://site.under.test.com/";
driver = new InternetExplorerDriver(AppDomain.CurrentDomain.BaseDirectory);
driver.Url = home;
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl(home + "secure/");
//code to handle login box goes here, never gets executed unless the dialog box
//is manually addressed or something times out in GoToURL(),
//and then the dialog box doesn't work.
The login box appears:
Click here for screenie of the login box
But the execution is stalled on the GoToUrl() call:
Click here for screenie of execution
Doesn't matter what code I place after this to handle the popup, execution is blocked until something times out inside GoToUrl().
Is this expected behavior? How does one get around it?
Clarification: The problem is not how to enter data into the popup. It is about the code execution not advancing to the point where I can enter data into the popup without intervention or timeout.
This works on Win8.1, but not on Win10
The Webdriver no longer officially supports Basic Authentication. It has been removed from the Java code and the .Net version works accidentally. From my experience you can expect it to work (for now) on Win7-8.1, but not on Win10
This from Selenium support:
The support of authentication dialogs was removed from the java bindings with this commit.
I am surprised, they are still present in the c# binding, because there is no support for basic authentication in the webdriver specification.
Not sure if you found the answer yet but here is what I found so far.
.GoToUrl waits for the page to load and since the page has not loaded yet, it waits and waits and throws exception.
You can enter the url usign Javascript. Below for is .Net code for it
string script = "window.location = \'" + url + "\'";
((IJavaScriptExecutor)driver).ExecuteScript(script);
You have to manage your own wait after using the above code.
And Selenium still doesnt work with the Windows Security dialog that you see after this (Or, I havent found any info anywhere that shows how to make Selenium work with this dialog)
The best solution I have found so far is to use AutoIT, and use TAB commands within AutoIT to enter username, move to password adn enter password and then do tab tab until you get to submit button and then click on this location. Please comment here if you have found any better solution than this until now

Getting Error when i trigger the script from TFS when the browser type is IE

We are doing the Continuous integration using C# selenium for web base application. We have trigger the script from TFS using the test agent. But the build or the execution is getting successful if the browser type is chrome. For the IE bower we are facing the issue. Please help us in resolving this issue.
Note: When we trigger manual execution from server , execution in IE happens successfully.
Below is my Exception screenshot.
enter image description here
Seems it related to the Webdriver.
Just try below things to check if that works for you:
1 .Try the latest IE
2 .Include setting capabilities of the browser when starting it. Try the below settings and see if it works to help it stay focused on the newly opened window.
capabilities = new DesiredCapabilities();
capabilities.setCapability("ignoreProtectedModeSettings", true);
capabilities.setCapability("ie.ensureCleanSession", true);
webDriver = new InternetExplorerDriver(capabilities);
3 .Edit the browser profile and increase timeout to 180 seconds or more from default 60 seconds. Please note that this constructor is available in .Net API only.
For internet explorer driver, you can use below syntax.
driver = new InternetExplorerDriver(#"z:\seleniumc", new InternetExplorerOptions(),TimeSpan.FromMinutes(5));
Refer to Selenium Webdriver for details.

WebDriver: Suddenly my stable tests fails with "Other Element Would Receive Click"

I have a dusin automated UI end-to-end tests in WebDriver with C# on Chrome. When I came back from vacation most of them stopped working with an error similar to each other - only the blocking element and the coordinates differ:
Result Message: System.InvalidOperationException : unknown error: Element is not clickable at point (184, 685). Other element would receive the click: <div>...</div>
(Session info: chrome=52.0.2743.82)
(Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.1.7601 SP1 x86_64)
Nothing related to the tests code or the business code was changed when they stopped working.
The elements we're trying to click are alle visible and unblocked by other elements when I'm debugging the tests.
I've tried adding extra synchronization functionality that makes sure that the elements are clickable before trying to click, which doesn't deem the elements unclickable.
Any help in solving or working around this is much appreciated.
If have tried all but never got success, Here is another solution provided by selenium to perform click using IJavascriptExecutor as below :-
IWebElement yourElement = driver.FindElement...
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
js.ExecuteScript("arguments[0].click()",yourElement);
Hope it works..:)
According to Selenium Release-Notes, an new NoSuchSessionException was introduced with the WebDriver v2.53.0
Java: Introducing NoSuchSessionException in the core API
This "missing" Session is making the Browser Unreachable.
BugTicket to the Chromium-Community, maintainig ChromeDriver, already exists:
https://bugs.chromium.org/p/chromium/issues/detail?id=615396
I am facing Problem on both ff and chrome.This ain't a Browser problem but a core WebDriver bug.

__IE_PrintType script error when calling WebBrowser.ShowPrintDialog from windows forms app

I've been tasked with fixing a bug in a windows forms application written in C# that basically allows the user to perform an operation then print a summary of the results by calling WebBrowser.ShowPrintDialog() on button_click. However, upon clicking the Print button, a javascript error is returned, but only in IE10 and IE11; older versions work fine. Unfortunately I'm unable to debug the script error because it causes the app to crash as it attempts to launch IE's debugger.
Line: 291
Error: Unable to get property '__IE_PrintType' of undefined or null reference
Basically, the results of the user's action are passed through to a browser via WebBrowser.Navigate where they are rendered on the client then can be printed.
browser.Navigate(new Uri(targetFile.ToString(), UriKind.Absolute));
Unfortunately, I have no clue where this script error is coming from or why. My first inclination was to print out the html output via MessageBox.Show, save it off, then open it directly in IE11 to see if the error reproduced, only to find out that it didn't; IE11 handles it just fine.
Further research led me to believe that compatibility mode is used when using the WebBrowser object, but opening the html in IE11 reveals that it's already using EDGE mode.
What am I missing here?

Categories

Resources