Below TestNG execution of test cases leads to failure.
Error - org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: socket hang up (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 56 milliseconds
#Test(description = "Test I")
public void TestI() {
System.out.println("Test I");
openApp();
checkForCondition();
}
#Test(description = "Test II")
public void TestII() {
System.out.println("Test II");
openApp();
checkForCondition();
}
Could you place all related stuff, not just two methods? I mean the class, where driver is initialized, called etc. Also I would look at your testng.xml file and pom.xml maven(if you're using it) as well.
I am trying to run MS Edge using the Microsoft webdriver with Selenium. The browser starts and get stuck before opening the URL.
I have created a C# MSTest Project and added Selenium.Microsoft.Webdriver.
Afterwards, I installed Selenium.WebDriver.MicrosoftDriver.
When I now run the test, Edge starts and get stuck immediately.
The error is:
An exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:49681/session. The status of the exception was ReceiveFailure, and the message was: Die zugrunde liegende Verbindung wurde geschlossen: Unbekannter Fehler beim Empfangen.
I also tried using Selenium.Microsoft.Webdriver2 and installing the Microsoft driver using DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
Windows 10 and Edge are v18363. The zoom is at 100%
Have you installed the Microsoft WebDriver in an elevated command prompt? You should run the cmd as Administrator when you using DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0.
Besides I installed the following NuGet Packages in my project:
Then run the following code to start a test:
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
namespace ecwebdriver
{
public class webdriver
{
static void Main(string[] args)
{
var driver = new EdgeDriver();
driver.Navigate().GoToUrl("https://www.bing.com/");
var element = driver.FindElementById("sb_form_q");
element.SendKeys("webdriver");
element.SendKeys(Keys.Enter);
System.Threading.Thread.Sleep(5000);
driver.Quit();
}
}
}
I am creating the object for class ApplicationBrowser which is present in one solution where I am passing one path as a string and it creates an instance of chrome driver. Chromedriver is the API present in the . When I do this I'm experiencing the following exception:
Could not load file or assembly 'WebDriver, Version=3.9.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
My Code:
ApplicationBrowser webApp = new ApplicationBrowser(path);
public ApplicationBrowser(string driverLocation)
{
ChromeOptions options = new ChromeOptions();
Wb = new ChromeDriver(driverLocation, options);
}
Looks like you are not declaring a WebDriver:
WebDriver wb = new ChromeDriver(options);
Missing the WebDriver in front of wb
Also, make sure you have the right WebDriver:
https://www.seleniumhq.org/download/
I have been trying to read a pdf which is opened in browser. through the following selenium code.
URL pdfURL = new URL(driver.getCurrentUrl());
InputStream is = pdfURL.openStream();
BufferedInputStream fileToParse= new BufferedInputStream(is);
PDFParser pdfParser=new PDFParser(fileToParse);
pdfParser.parse(); // getting error here !!!
Getting Error:
java.io.IOException: Error: End-of-File, expected lineenter code here
How to get rid of this error?
I have extracted the following code from selenium IDE.(c# remote control)
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;
namespace SeleniumTests
{
[TestFixture]
public class MyFirstVCTest
{
private ISelenium selenium;
private StringBuilder verificationErrors;
[Test]
public void TheNewTest()
{
selenium.Open("/");
}
[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*chrome","http://demo.volunteercampaigns.com/");
selenium.Start();
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
selenium.Stop();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void TheMyFirstVCTest()
{
selenium.Open("/?AspxAutoDetectCookieSupport=1");
selenium.Click("link=Login");
selenium.WaitForPageToLoad("30000");
selenium.Type("id=ctl00_ContentPlaceHolder1_txtEmailAddress", "elonadminss#eeeorbees.com");
selenium.Type("id=ctl00_ContentPlaceHolder1_txtPassword", "orbs123");
selenium.Click("id=ctl00_ContentPlaceHolder1_btnlogin");
selenium.WaitForPageToLoad("30000");
selenium.Click("id=ctl00_lblUserName");
selenium.Click("id=ctl00_lnkSignOut");
selenium.WaitForPageToLoad("30000");
}
}
}
i created a webform and added a button there.
in button click event i wrote this code
SeleniumTests.MyFirstVCTest m = new SeleniumTests.MyFirstVCTest();
m.SetupTest();
m.TheMyFirstVCTest();
m.TeardownTest();
i included all .dll files. its running fine(no errors and warnings).
but after clicking button i am getting the following error
No connection could be made because the target machine actively refused it 127.0.0.1:4444
what should i do??
thanks in advance..
Note to viewers: This post may help you : No connection could be made because the target machine actively refused it
"...the target machine actively refused it" means the server could be reached and responded within the timeout, but the specified port wasn't open. This can have several reasons, e.g. a local firewall blocking the connection. Are you sure the server is listening on the right IP/port?
To add more clarity for the readers: Start selenium server using the followings basic steps:
Download selenium -server standalone from official selenium download
page.
Open command prompt.
Navigate to the folder using "Cd ".
Add this command: "java - jar ".
Hit enter.
Selenium server will be started.
I get the same error, but on a different line of code. Hopefully this might help someone somewhere even if it doesn't answer the initial question.
public override void SetupTest()
{
Driver = new FirefoxDriver();
base.SetupTest();
}
I'm using the WebDriver (I don't run the Selenium server), and the constructor of FirefoxDriver throws the Exception.
Sometimes I get this exception:
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
Additional information: No connection could be made because the target machine actively refused it
with this call stack:
WebDriver.dll!OpenQA.Selenium.Firefox.Internal.ExtensionConnection.ConnectToBrowser(System.TimeSpan timeToWait) Line 247 C#
WebDriver.dll!OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start() Line 98 C#
WebDriver.dll!OpenQA.Selenium.Firefox.FirefoxDriver.StartClient() Line 237 C#
WebDriver.dll!OpenQA.Selenium.Remote.RemoteWebDriver.RemoteWebDriver(OpenQA.Selenium.Remote.ICommandExecutor commandExecutor, OpenQA.Selenium.ICapabilities desiredCapabilities) Line 89 C#
WebDriver.dll!OpenQA.Selenium.Firefox.FirefoxDriver.FirefoxDriver(OpenQA.Selenium.Firefox.FirefoxBinary binary, OpenQA.Selenium.Firefox.FirefoxProfile profile, OpenQA.Selenium.ICapabilities capabilities, System.TimeSpan commandTimeout) Line 172 C#
WebDriver.dll!OpenQA.Selenium.Firefox.FirefoxDriver.FirefoxDriver(OpenQA.Selenium.Firefox.FirefoxBinary binary, OpenQA.Selenium.Firefox.FirefoxProfile profile, System.TimeSpan commandTimeout) Line 167 C#
WebDriver.dll!OpenQA.Selenium.Firefox.FirefoxDriver.FirefoxDriver(OpenQA.Selenium.Firefox.FirefoxBinary binary, OpenQA.Selenium.Firefox.FirefoxProfile profile) Line 154 C#
WebDriver.dll!OpenQA.Selenium.Firefox.FirefoxDriver.FirefoxDriver(OpenQA.Selenium.Firefox.FirefoxProfile profile) Line 132 C#
SetupTest() Line 513 C#
Sometimes I get this exception:
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
Additional information: Only one usage of each socket address (protocol/network address/port) is normally permitted
with this call stack:
WebDriver.dll!OpenQA.Selenium.Firefox.Internal.ExtensionConnection.DetermineNextFreePort(string host, int port) Line 161 C#
WebDriver.dll!OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start() Line 88 C#
[same as above]
But one thing I didn't realize at first is that if you continue execution (F5), everything is fine. The Exception must be handled in the WebDriver.
The only thing is that I had the DEBUG/Exceptions/CLR Exceptions: Thrown [checked].
Just uncheck that and everything runs without throwing/breaking. Took me a while to realize that. Leftovers of a previous debugging session...
I got this because a part of my code held a reference to a stale driver.
var driver1 = new OpenQA.Selenium.Firefox.FirefoxDriver();
driver1.Close();
driver1.Quit();
driver1.Dispose();
var x = driver1.FindElements(...);
This is the way i do it, the structure of my class.
[TestFixture, Parallelizable(ParallelScope.None)]
public class UserTest : BaseTestClass
{
[SetUp]
public void SetUp()
{
ChromeOptions options = new ChromeOptions();
//options.AddArgument("--headless");
options.AddArgument("--start-maximized");
var driver = new ChromeDriver(options);
WebDriver = WebDriverExtended.InitWebDriver(driver, driver.Url);
WebDriver.Start();
}
[TearDown]
public void Cleanup()
{
//Dispose after every single test, fixed the problem.
WebDriver.Close();
WebDriver.Quit();
WebDriver.Dispose();
}
[Test]
public void LoginTest()
{
//My test ...
}
}
I am currently using Selenium.Support v3.6.0 and Selenium.WebDriver v3.6.0.
Disposing the webdriver fixed my problem
No connection could be made because the target machine actively
refused it 127.0.0.1:4444
I also encountered this type of error.
What I was doing is I was closing the browser and quitting the driver at end of the test, but I forgot to make Webdriver wait = null;
So again when I tried to open a new browser for the next test, it will eventually start the browser and redirects to the URL but at the time of interacting it was giving me this error No connection could be made because the target machine actively refused it.
So I found that I was using wait of closed driver instance.
So please check whether you are using anything like that.
In my case it was a problem with the scope of the services. The ones that were using WebDriver were registered as singletons, and every subsequent request after the first one was failing. (even though I was closing and recreating the web driver instance manually after each request). Once I changed the scope to transient it worked fine.
Make sure the remote machine on which scripts are to be run is up and working. Secondly make sure chrome driver and chrome is update on it. Lastly no firewall is blocking ur access to remote machine.
PS: Manually close the selenium server and restart it.
For me, this problem was solved by changing settings within Chrome, as follows:
go into Chrome Menu Settings (three vertical dots / hamburger menu)
scroll down to Advanced, and expand it
System > Open Proxy Settings
UN-check "Automatically Detect Settings"