I have some WatiN tests in IE that I'm porting to FireFox (3.6, 4.0 not supported yet I think) and I have an error in the following code:
var browser = new FireFox(_baseUri);
browser.RunScript("alert('hello');")
Even though it runs fine in IE. I get the error "{"Error sending last message to jssh server: ReferenceError: alert is not defined"}".
I've tried lots of variations without any success. Any ideas?
Turns out I needed
browser.RunScript("window.alert('hello');");
D'oh!
Related
I have created a basic Selenium Console App in C# that opens a URL, signs-in and does some activity.
The code is working fine in Dev VM, but the same code isn't working in Production VM.
In Prod VM, the code just opens the URL (sign-in page) and it doesn't process anything.
I have googled and tried adding different options, but nothing worked.
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--incognito");
chromeOptions.AddArgument("no-sandbox");
chromeOptions.AddArgument("disable-infobars");
chromeOptions.AddArgument("--ignore-ssl-errors");
chromeOptions.AddArgument("--ignore-certificate-errors-spki-list");
chromeOptions.AcceptInsecureCertificates = true;
string path = #"local Chromedriver.exe(103.0.5060.134) path";
IWebDriver driver = new ChromeDriver(path, chromeOptions, TimeSpan.FromMinutes(2));
driver.Url = "url";
I have chromedriver 103.0.5060.134, the same as the version of the chrome browser.
Not sure what else I have to check.
The main error is:
[67852:69648:0818/112450.083:ERROR:ssl_client_socket_impl.cc(996)] handshake failed; returned -1, SSL error code 1, net_error -101
which is not happening in dev instance.
This is what I get in Production:
Chrome version
UPDATE
I have updated Chrome driver to 104 version and chrome browser to 104.0.5112.102 but still getting same error.
Updated Chrome version
and I have the same driver version and chrome version in dev and it is working fine. Is there a way that I can get additional logs? Not sure why exactly failing in Production.
To start with, this error message...
[67852:69648:0818/112450.083:ERROR:ssl_client_socket_impl.cc(996)] handshake failed; returned -1, SSL error code 1, net_error -101
...implies that the handshake between ChromeDriver and Chrome Browser failed at some point.
Details
As per ERROR:ssl_client_socket_openssl.cc handshake failed the main issue is the failure of handshake when ChromeDriver handshakes with SSL pages in Chrome. Though Chromium team conducts test for SSL handshake through net_unittests, content_tests, and browser_tests but were not exhaustive. Some usecases are left out relying on the upstream tests.
Mandatory checks
Always ensure that:
Selenium is upgraded to current released Version 4.4.0.
ChromeDriver is updated to current ChromeDriver v104.0 level.
Chrome Browser is updated to current chrome=104.0 (as per chromedriver=104.0 release notes).
Unwanted Arguments
It's not that super clear why you need to add so many arguments. However,
--incognito: Isn't necessary as ChromeDriver initiated sessions are sandboxed by default. So you can discard it.
--no-sandbox: Isn't needed unless your program crashes during startup being executed as a root user (administrator) on Linux. So you can remove it.
disable-infobars: It's no more effective. So you can discard it.
--ignore-certificate-errors-spki-list: Have no effect unless --user-data-dir argument is also present. So you can remove it.
Incorporating the above mentioned changes, you would be good to go.
The code below runs fine when my teammate runs on her machine but errors on this line when I run on my machine. It mouse over an element and clicks on the first option in there. Our chrome version are same. I restarted my machine, re-installed Chrome, killed all active processes.. still doesn't get past this. Is there anything specific I should be looking for? Checked all existing extensions and no dodgy ones in there.
public static void MouseOveronElementandClick(IWebDriver driver, IWebElement ele)
{
waitTillElementExist(ele, WaitElement());
Actions a = new Actions(driver);
a.MoveToElement(ele).Build().Perform();
//a.Click().Perform();
SleepTimeOut(2000);
IJavaScriptExecutor ex = (IJavaScriptExecutor)driver;
ex.ExecuteScript("arguments[0].click();", ele);
}
Error:
Error
Disabled all extensions and ran again.. still the same
Looks like your element [ele] is "not interactable" when you're calling Perform(). Might be timing differences or different window sizes with your teammate's machine, or who knows. Try a Thread.Sleep() before your MoveToElement(), or stepping through code and seeing if the element does in fact look interactable. If it works when you step through code slowly, then it's a timing problem.
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.
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?
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.