webdriver is giving timeout error after opening IE start page - selenium

I am moving from selenium 3 to 4 and trying to run my tests in edge-IE mode. After starting the IEDriver with
var driver = new InternetExplorerDriver(ieOptions);
the browser opens but then does not hand control back the the code for the next step, instead I get a time out error.
here is my code.
var options = new InternetExplorerOptions();
options.AttachToEdgeChrome = true;
options.EdgeExecutablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe";
//options.BrowserCommandLineArguments = "-private";
IWebDriver edgeIeMode = new InternetExplorerDriver(options);
here is the error
Unhandled Exception, See screenshotOpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:63459/session/197d3eaa-361d-433e-b8b5-0b5d6acb1e7b/url timed out after 60 seconds. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at OpenQA.Selenium.Remote.HttpCommandExecutor.d__35.MoveNext()

Verify that your edge and webdriver versions are up to date. Typically this happens when a version mismatch can't connect to the browser. I'm not sure if edge uses an IEdriver.exe executable, but if it does, verify that version too.

Related

c# - Selenium 3.14.0 + BrowserStack - Webdriver exception - Receive failure and instantiation fails

I recently upgraded to Selenium 3.14 from 3.9.1 . Now everytime I run, I am getting below error where I try to instantiate the webdriver. Below is the line where it fails and throws an expecption.
When I downgrade to 3.9.1 it works fine. Is there something I am missing? Has anyone see this before?
I am using c# + Spec flow + BrowserStack grid.
Please let me know if you need more information. This is my first post and have googled and researched but couldn't find any information regarding this error.
_driver = new RemoteWebDriver(new Uri("http://" + browserStackConfig["BSserver"] + "/wd/hub/"), capability, new TimeSpan(0,0,30));
Result Message:
OneTimeSetUp: OpenQA.Selenium.WebDriverException : A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://hub-cloud.browserstack.com/wd/hub/session. The status of the exception was ReceiveFailure, and the message was: The underlying connection was closed: An unexpected error occurred on a receive.
----> System.Net.WebException : The underlying connection was closed: An unexpected error occurred on a receive.
----> System.IO.IOException : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
----> System.Net.Sockets.SocketException : An existing connection was forcibly closed by the remote host
Selenium made a change on Jul 25th to expose the Proxy property from HttpCommandExecutor class ( Below is the link) . You would expect that if no Proxy is passed then the Selenium would use Default Web Proxy. This is not the case. The proxy is being set to null which would cause the executor to fail while instantiating the driver.
https://github.com/SeleniumHQ/selenium/commit/52969e49a16efee7efb52893addde19605162a66#diff-bc8a75c5cb22ca86093a1bbced41a6ee
Fix:
I made a simple change in my code to pass the default web proxy. Below is the code snippet. This fixed my issue.
var executor = new HttpCommandExecutor(new Uri("http://" + browserStackConfig["BSserver"] + "/wd/hub/"), new TimeSpan(0, 0, 0, 30));
executor.Proxy = WebRequest.DefaultWebProxy;
_driver = new RemoteWebDriver(executor, capability);

Running Selenium scripts on Bluemix

I am completely new to testing and Bluemix. As per my requirement, I need to run Selenium scripts on Bluemix. I am using Automated Accessibility Tester service in Bluemix for running Selenium scripts. I have added the service to my space and added the aat.jar and the Tool Configuration JSON file to my working directory. I have added some scripts to my test case for running on remote server. However, I am getting the following error message:
error Message: setEnabledIds INFO: Enabled Rulesets: IBM_DCP080115
FAILED CONFIGURATION: #BeforeClass setUp
org.openqa.selenium.remote.UnreachableBrowserException: Could not
start a new session. Possible causes are invalid address of the remote
server or browser start-up failure.
This is the script that I have added:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ComplianceConfig config = new ComplianceConfig(new String[] { "IBM_DCP080115" });
driver = ComplianceDriverRemote.init(config, capabilities);
I am getting an error at driver = ComplianceDriverRemote.init(config, capabilities);
For running test cases on Bluemix, I am following this link: https://console.ng.bluemix.net/docs/services/ecsdashboard/index.html

Selenium Continuous Integration with Team Services

I have a set of Selenium tests in a test project within my solution, and they run just fine from within Visual Studio. However, when I check in code and they run as part of my continuous integration build profile, they fail.
A brief explanation of the setup:
1) Code is checked into the build agent server.
2) The project is then built, and then deployed to server 2 (which is remote from the build server).
3) Unit tests then run.
Here is an example unit test:
public void Login_InvalidAccessUrl_ShowMesage()
{
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
driver.Navigate().GoToUrl("https://testsite.company.com/Login");
IWebElement el = driver.FindElementById("invalidAccessUrlSection");
Assert.AreNotEqual(el, null);
}
This runs beautifully from Visual Studio, but when CI runs the same tests, I get the following:
Error Message:
Test method eNotify.Staff.Tests.SeleniumTests.Login_InvalidAccessUrl_ShowMesage threw exception:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:11570/session timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out
TestCleanup method eNotify.Staff.Tests.SeleniumTests.Dispose threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object..
Stack Trace:
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor()
at eNotify.Staff.Tests.SeleniumTests.Login_InvalidAccessUrl_ShowMesage()
TestCleanup Stack Trace
at eNotify.Staff.Tests.SeleniumTests.Dispose()
Am I missing a driver or some software? As far as I know, there is nothing listening on port 11570.
First, make sure the VSTS agent is running as Interactive process.
Secondly, adding no-sanbox argument to ChromeDrive instance. For example:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("no-sandbox");
driver = new ChromeDriver(chromeOptions);

Possible reasons for Selenium RemoteWebDriver command timeouts

We have a number of Selenium tests running 24/7 and a few times a day we are getting random
webdriver timeout exception. For example:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://*.*.*.*:4444/wd/hub/session/4957b6a8-c885-4dd7-98ab-373f35619495/url timed out after 120 seconds. ---> System.Net.WebException: The operation has timed out
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.get_Url()
...
Usually it happens in random places (when fetching the current URL, when clicking an element, finding an element, etc.) and in different tests.
RemoteWebDriver's command timeout for HTTP requests is set to 120s and none of the timeouts set with Manage().Timeouts().* exceed 60 seconds.
My question is, what could be the possible reasons for the command timeout?
It looks like Selenium or possibly the ChromeDriver just locks occasionally for whatever reason. Although I am unable to verify anything visually since the tests are executed on a headless machine.
Could it be that we overlooked or misunderstood some timeout setting?
Versions:
Selenium v2.42.2, .NET bindings v2.40.0, ChromeDriver 2.10

Unable to set proxy :selenium.common.exceptions.WebDriverException:Access Denied

I want to use Selenium Webdriver and I am unable to do so because when I run my code, I get the following exception.
My code is very basic and as follows.
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.google.com.bh")
assert "Google" in driver.title
driver.close()
Exception Message
selenium.common.exceptions.WebDriverException: Message: '<HTML><HEAD>\n<TITLE>Access Denied</TITLE>\n</HEAD>\n<BODY>\n<FONT face="Helvetica">\n<big><strong></strong></big><BR>\n</FONT>\n<blockquote>\n<TABLE border=0 cellPadding=1 width="80%">\n<TR><TD>\n<FONT face="Helvetica">\n<big>Access Denied (authentication_failed)</big>\n<BR>\n<BR>\n</FONT>\n</TD></TR>\n<TR><TD>\n<FONT face="Helvetica">\nYour credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.\n</FONT>\n</TD></TR>\n<TR><TD>\n<FONT face="Helvetica">\nThis is typically caused by an incorrect username and/or password, but could also be caused by network problems.\n</FONT>\n</TD></TR>\n<TR><TD>\n<FONT face="Helvetica" SIZE=2>\n<BR>\nFor assistance, contact your network support team.\n</FONT>\n</TD></TR>\n</TABLE>\n</blockquote>\n</FONT>\n</BODY></HTML>\n'
It opens firefox but after that it is unable to connect to google or any other local sites.
The exception is at driver = webdriver.Firefox()
I googled around and I followed the link on SO.
But unfortunately I still get the same error.
I cannot run as the root user. I changed my proxy settings and set No Proxy element for localhost as well as mentioned in the link.
I am using Python 2.7 and have installed selenium 2.31 version.
I also tried setting proxy.
myProxy = "*********:8080"
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
'noProxy': 'localhost,127.0.0.1,*.abc'
})
driver = webdriver.Firefox(proxy=proxy)
I also tried to set the proxy to system's proxy i.e., in the above code, 'proxyType': ProxyType.SYSTEM
But it again gives the above exception message.
is there a place where I have to set my username and password?
Any help would be appreciated!
Remove proxy settings from all the browsers on the system manually. I had IE, Firefox and Google Chrome.
When I removed the proxy settings of all the browsers and enabled the proxy only on Firefox,it worked without giving any errors. I do not know the exact reason why this works like this, may be got to do with the registry settings on windows which I am not sure about.
After doing the above said, I ran the basic code and it worked fine.
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.google.com.bh")
assert "Google" in driver.title
driver.close()
I didn't set the proxy explicitly also. By default, it had taken the system's proxy settings. Hope this would help others facing similar issue.