I'm Currently working in Automation test scripts in visual studio for IE browser version 11 using c#.
My test cases not able to run continuously one after the other.It working fine for only one test case, when it trying to attempt 2nd test cases encountering error
Specification:
IE browser ver 11
Selenium.WebDriver.IEDriver
C# (visual studio)
Error:
A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:57525/session//url. The status of the exception was UnknownError, and the message was: No connection could be made because the target machine actively refused it No connection could be made because the target machine actively refused it'
var ieoptions = new InternetExplorerOptions();
ieoptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
ieoptions.EnsureCleanSession = true;
builder.RegisterType<InternetExplorerDriver>()
.WithParameter(new TypedParameter(typeof(string), "."))
.WithParameter(new TypedParameter(typeof(InternetExplorerOptions), ieoptions))
.AsImplementedInterfaces()
.InstancePerLifetimeScope();
Note: The same code and approach working for other drivers like Chrome, Chromium and Firefox
Related
I am using C# Selenium for automated testing, and after the most recent chromedriver update 89.0.4389.2300, Google chrome starts and crashes right away. The weirdest thing is that when I am running it on my local, everything works fine, but I am also using Azure pipelines to run my tests on a server. The server one gives me this:
OpenQA.Selenium.WebDriverException : unknown error: Chrome failed to start: crashed.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
I have googled around and tried things like adding chromeOptions.AddArgument("--no-sandbox") and chromeOptions.AddArguments("disable-dev-shm-usage") but nothing helps. Chrome on my server is updated to the correct version too. The tests run headless.
Anyone else is having this issue?
The error mentions that chromedriver could not bind to open debug port on running Chrome.
Possible cases I met with:
old version of Chrome browser or chromedriver - since some version the port has changed
wrong Chrome binary location (chromedriver is looking for C:\Program Files (x86)\Google\Chrome\Application\chrome.exe)
I created a very simple C# project to test Selenium and Chrome Driver, but when I run it, it gets stuck at the very first line, ie. creating ChromeDriver object.
I have set up as following:
.NET Core 3.1 console app (also tried .NET 4.7)
Installed Selenium.WebDriver 3.141.0 and Selenium.WebDriver.ChromeDriver 87.0.4280.8800.
My Chrome version is "Version 87.0.4280.88 (Official Build) (64-bit)". I have double-checked compatibility with Chrome and ChromeDriver.
Code:
using OpenQA.Selenium.Chrome;
namespace MyFirstSelenium
{
class Program
{
static void Main(string[] args)
{
ChromeDriver chrome = new ChromeDriver();
chrome.Navigate().GoToUrl("https://www.google.co.jp/");
}
}
}
visual studio screen
chromedriver.exe is copied to the debug folder as expected, so I assume the problem is neither compatibility nor path.
chromedriver
When I run the code, the result is an empty window with 'data' in the address bar. No error is thrown. I have searched for several hours and found some articles, but most of them are old and none of these answers led to success.
Any help is appreciated. Thank you.
Added chromedriver.exe verbose console output.
#Piotr M.
chromedriver console
logfile
https://drive.google.com/file/d/1ECOS8E55aaTFV63e8P-7n6uRVcf49PRN/view?usp=sharing
New code
Works when I first execute "chromedriver.exe --verbose --log-path=chromedriver.log", but without it, it throws WebDriverException.
OpenQA.Selenium.WebDriverException: 'A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL localhost:9515/session. The status of the exception was UnknownError, and the message was: No connection could be made because the target machine actively refused it. No connection could be made because the target machine actively refused it.'
var chromeOptions = new ChromeOptions();
chromeOptions.BrowserVersion = "87";
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:9515"), chromeOptions);
Possibly a classic case of cyclic redundancy.
chrome is a reserved word, you may have to change the variable name to something else e.g. chromex. So your effective line of code will be:
ChromeDriver chromex = new ChromeDriver();
Additional Consideration
Consider the following aspects aswell:
Instead of using the ChromeDriver class use the IWebDriver interface.
IWebDriver driver = new ChromeDriver();
Instead of the partial url google.co.jp/ you need to pass the complete url through GoToUrl() as follows:
driver.Navigate().GoToUrl(#"https://www.google.co.jp/");
I am trying to connect to a remote ssh server using the SshNet package.
My code looks like this:
List<AuthenticationMethod> authenticationMethods = new List<AuthenticationMethod>();
authenticationMethods.Add(new PasswordAuthenticationMethod(SSHusername, SSHpassword));
SSHConnection = new SshClient(new ConnectionInfo(ip, Int32.Parse(SSHport), SSHusername, authenticationMethods.ToArray()));
SSHConnection.Connect();
When the program tries to make the connection, I get the following exception:
Exception thrown: 'Renci.SshNet.Common.SshConnectionException' in Renci.SshNet.dll
An exception of type 'Renci.SshNet.Common.SshConnectionException' occurred in Renci.SshNet.dll but
was not handled in user code
Server response does not contain SSH protocol identification.
I have been searching for a solution for 2 hours now, but haven't been able to fix it.
Looking through the source code of SshNet if found this error is thrown when the client doesn't get an ssh version from the server. I'm not an expert in this field, but looking at wireshark the server sends a packet with this info:
SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.1
I'm pretty sure this is the ssh version it's looking for. So I hope one of you guys can tell me what else I can try to fix this.
My Core project has target framework .NET standard 2.0, the UWP project's min version is Windows 10 1903. The SshNet package is on version 2016.1.0
My Chrome browser is updated to version 78 and when I tried to execute any code of automation, it shows the error
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1573451703.668][WARNING]: Timed out connecting to Chrome, retrying...
Nov 11, 2019 11:25:05 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[1573451709.039][WARNING]: Timed out connecting to Chrome, retrying...
How can I fix it?
This error message...
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1573451703.668][WARNING]: Timed out connecting to Chrome, retrying...
Nov 11, 2019 11:25:05 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[1573451709.039][WARNING]: Timed out connecting to Chrome, retrying...
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Analysis
The first log message:
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
is part of the startup log when using ChromeDriver and is informative in nature.
You can find a detailed discussion in How do I protect the ports that chromedriver use?
The following log message:
[1573451703.668][WARNING]: Timed out connecting to Chrome, retrying...
indicates there are some incompatibility between the version of the binaries you are using.
Solution
Ensure that:
JDK is upgraded to current levels JDK 8u222.
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v78.0 level.
Chrome is updated to current Chrome Version 78.0 level. (as per ChromeDriver v78.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
(WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
(LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
I have fixed this issue of timeout / Connection reset by changing my code from:
public void AfterScenario(Scenario sc) {
driver.close();
driver.quit();
driver = null;
}
to:
public void AfterScenario(Scenario sc) {
driver.quit();
driver = null;
}
So basically I removed the driver.close() and this fixed my issue. I do not know why this is happening, but experts can explain more...
I had to update to the dev version of chrome 79 and the latest dev version of chromedriver to make it work. Although I've run against other issues with this version, so I don't know if its a good solution.
I have been trying to connect to the Windows Service created in this tutorial:
http://www.asp.net/signalr/overview/deployment/tutorial-signalr-self-host
The thing is that I do can connect to it using its own client. However, I've tried to connect to it from a console application and haven't had success. Moreover, if I host the SignalR Hub in a console application I can connect to it successfully.
The errors that I got say that my client version isn't compatible with the server and that the connection was refused.
This is how my attempt to connect looks like:
IHubProxy _hub;
string url = #"http://localhost:8080/";
var connection = new HubConnection(url);
_hub = connection.CreateHubProxy("MyHub");
_hub.On("addMessage", x => ShowMessage(x));
connection.Start().Wait();
UPDATE:
-Errors Messages:
1.
Exception:Caught: "You are using a version of the client that isn't compatible with the server. Client version 1.4, server version 1.3." (System.InvalidOperationException)
A System.InvalidOperationException was caught: "You are using a version of the client that isn't compatible with the server. Client version 1.4, server version 1.3."
Time: 2/20/2015 12:03:36 PM
Thread:Worker Thread[5924]
2.
Exception:Thrown: "No connection could be made because the target machine actively refused it" (System.Net.Sockets.SocketException)
A System.Net.Sockets.SocketException was thrown: "No connection could be made because the target machine actively refused it"
Time: 2/20/2015 12:03:36 PM
Thread:Worker Thread[3320]
As pointed by Christophe, this question is a duplicate of SignalR Java client only supports exactly 1.3 and, in my case, was solved by uninstalling and re-installing all the SignalR/Owin packages.