Selenium grid hub console is returning 500 - selenium

I have setup a selenium grid with port 4444 for hub and node with port 5555. When I try to access console of the hub by http://localhost:4444/wd/hub/console I am getting the below logs.
When i tried to access the session http://localhost:4444/wd/hub/session of my grid getting below errors.
I am using C#.net for my test and from my test when I try to initilaize the remotedriver instance, I am getting error
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in D:\SeleniumCode\selenium\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 1384
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) in D:\SeleniumCode\selenium\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 1187
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) in D:\SeleniumCode\selenium\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 1114
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) in D:\SeleniumCode\selenium\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 141
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout) in D:\SeleniumCode\selenium\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 128
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities) in D:\SeleniumCode\selenium\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 117
Below is the code.
` var driverContext = new WebDriverContext();
DesiredCapabilities capability = DesiredCapabilities.Chrome();
capability.Platform = new Platform(PlatformType.Windows);
try
{
driverContext.Driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);
driverContext.Driver.Navigate().GoToUrl(url);
context = driverContext;
}
catch(Exception ex)
{
}
return driverContext;`

There are three issues that have been mentioned in this post.
Grid console url problem.
You are hitting an invalid Grid console URL. The correct URL is http://localhost:4444/grid/console.
How to get the session details for a particular session in Grid.
For you to be able to access the details of a session, you should be hitting the URL http://localhost:4444/grid/api/testsession?session=%s where %s represents the session id that you obtain from RemoteWebDriver. SessionId
Encountering an issue when trying to instantiate RemoteWebDriver.
W.r.t the error that you are getting when you are trying to instantiate a new RemoteWebDriver instance, I can't seem to find anything that stands out (I am Java guy so I can't read C# full fledgely, but looking at the code snippet nothing stands out).
The exception however suggests
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in D:\SeleniumCode\selenium\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 1384
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) in D:\SeleniumCode\selenium\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 1187
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) in D:\SeleniumCode\selenium\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 1114
that you may have an issue with the ChromeDriver binary not being available in the PATH variable. Please check to see if its available in your path and if it can be spun off by running chromedriver from a command prompt ? Also you might want to cross check its presence in the PATH variable by running echo %PATH% and then scanning the output to see if it includes the directory in which chromedriver exists.

Related

Chromedriver doesn't return a control when it's started

I am using pretty old chromedriver 2.38.0.1 and cannot use any newer version since Chrome wouldn't work on it.
So when I launch a test on chromedriver 2.39.0 - 80.0.3987.1600-beta Chrome is started but it doesn't return a control. It crashes on
driver = new ChromeDriver();
Got next message in console:
Starting ChromeDriver 76.0.3809.126 (d80a294506b4c9d18015e755cee48f953ddc3f2f-refs/branch-heads/3809#{#1024}) on port 56951
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
DevTools listening on ws://127.0.0.1:63198/devtools/browser/96d16462-dfb4-48d0-b4f7-a9c1be000b50
[23236:20720:0905/154153.867:ERROR:ssl_client_socket_impl.cc(946)] handshake failed; returned -1, SSL error code 1, net_error -100
[15164:21256:0905/154153.867:ERROR:connection_factory_impl.cc(413)] Failed to connect to MCS endpoint with error -100
[15164:21256:0905/154217.733:ERROR:connection_handler_impl.cc(399)] Received message of invalid type 84
Tried it on C# and Java and in both cases have the same issue.
I have next options but don't think that I may somehow cause the problem:
private static ChromeOptions GetChromeOptions()
{
String userProfile = Config.TestInputDirectory + "ChromeProfile";
var userProfile = "ChromeProfile";
options.AddArguments("user-data-dir=" + userProfile);
options.AddAdditionalCapability("useAutomationExtension", false);
options.AddExcludedArgument("enable-automation");
options.AddArguments("--incognito");
options.AddArguments("--disable-dev-shm-usage");
options.AddArguments("--no-sandbox");
options.AddArguments("start-maximized");
options.AddArguments("--disable-gpu");
return options;
}
Google Chome version is 76.0.3809.132 (Official Build) (32-bit).
Note: chrome is controlled by administrator so I cannot download it manually from the official website and install.
Any suggestions what may cause it and how to fix it?
Update 1:
Added Result StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
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(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor()
at UnitTestProject1.UnitTest1.TestMethod1() in C:\Users\.....\UnitTest1.cs:line 12
Result Message:
Test method UnitTestProject1.UnitTest1.TestMethod1 threw exception:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:54932/session timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out.
Update 2:
Starting ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945#{#614}) on port 55361
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[12716:12284:0207/124619.539:ERROR:configuration_policy_handler_list.cc(90)] Unknown policy: EnableCommonNameFallbackForLocalAnchors
[12716:12284:0207/124619.540:ERROR:configuration_policy_handler_list.cc(90)] Unknown policy: EnableSha1ForLocalAnchors
[12716:12284:0207/124619.541:ERROR:configuration_policy_handler_list.cc(90)] Unknown policy: WelcomePageOnOSUpgradeEnabled
[12716:12284:0207/124620.242:ERROR:configuration_policy_handler_list.cc(90)] Unknown policy: EnableCommonNameFallbackForLocalAnchors
[12716:12284:0207/124620.244:ERROR:configuration_policy_handler_list.cc(90)] Unknown policy: EnableSha1ForLocalAnchors
[12716:12284:0207/124620.244:ERROR:configuration_policy_handler_list.cc(90)] Unknown policy: WelcomePageOnOSUpgradeEnabled
DevTools listening on ws://127.0.0.1:55372/devtools/browser/f0c55ef0-77be-436b-a60f-ee210dfeadf3
Unhandled Exception: OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:55361/session timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out.
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
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(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options)
at ConsoleApp1.Program.PrepareDriver() in C:\Users\...\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:line 22
at ConsoleApp1.Program.Main(String[] args) in C:\Users\...\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:line 11
Press any key to continue . . .

Error initializing WebDriver Chrome causing failure to wait for extension background to load

I am using Selenium C# + LeanFT to automate a web application. I sometimes get this error in Visual Studio, and I do not know why. Can someone shed light on how I might handle this:
Error initializing WebDriver Chrome -> unknown error: failed to wait for extension background page to load: chrome-extension://hpoiplhbnkgnpjkkilfahkkcimachkkj/Agent/Ext/bg-loader.html
from timeout
(Driver info: chromedriver=2.37.543627 (63642262d9fb93fb4ab52398be4286d844092a5e),platform=Windows NT 10.0.16299 x86_64)Automation.Test.Framework.Models.Exceptions.AtGenericException: Error initializing WebDriver Chrome ---> System.InvalidOperationException: unknown error: failed to wait for extension background page to load: chrome-extension://hpoiplhbnkgnpjkkilfahkkcimachkkj/Agent/Ext/bg-loader.html
from timeout
(Driver info: chromedriver=2.37.543627 (63642262d9fb93fb4ab52398be4286d844092a5e),platform=Windows NT 10.0.16299 x86_64)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
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(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at Automation.Test.Framework.Decorators.ChromeDriverDecorator..ctor(String chromeDriverDirectory, ChromeDriverOptions options)
at Automation.Test.Framework.Decorators.AtWebDriver.get_GetDriver()
--- End of inner exception stack trace ---
at Automation.Test.Framework.Decorators.AtWebDriver.get_GetDriver()
at Symphony.AcceptanceTests.Hooks.TestHook.RegisterAndInitializeWebDriver() in C:\Users\amaddox\Desktop\H\Symphony.AcceptanceTests\Symphony.AcceptanceTests\Hooks\TestHook.cs:line 161
at lambda_method(Closure , IContextManager )
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireScenarioEvents(HookType bindingEvent)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioStart(ScenarioInfo scenarioInfo)
at TechTalk.SpecFlow.TestRunner.OnScenarioStart(ScenarioInfo scenarioInfo)
at Symphony.AcceptanceTests.Epics.CC_TransitionFiles.Feature._9317_TransitionFilesUploadFeature.ScenarioSetup(ScenarioInfo scenarioInfo)
at Symphony.AcceptanceTests.Epics.CC_TransitionFiles.Feature._9317_TransitionFilesUploadFeature.PBIXXXXBulkUploadStructuredDocs() in C:\Users\amaddox\Desktop\H\Symphony.AcceptanceTests\Symphony.AcceptanceTests\Epics\CC - Transition Files\Feature\9317_TransitionFilesUpload.feature:line 31
at TechTalk.SpecRun.Framework.TaskExecutors.StaticOrInstanceMethodExecutor.ExecuteInternal(ITestThreadExecutionContext testThreadExecutionContext)
at TechTalk.SpecRun.Framework.TaskExecutors.StaticOrInstanceMethodExecutor.Execute(ITestThreadExecutionContext testThreadExecutionContext)
at TechTalk.SpecRun.Framework.TestAssemblyExecutor.ExecuteTestNodeTask(TestNode testNode, ITaskExecutor task, TraceEventType eventType)

chromedriver.exe not working in Windows Server 2012

I am using selenium and chromedriver for testing. While running my code on window server 2012, the task manager is showing the chromedriver.exe process is running but after 60 second.
I am getting the following exception:
System.InvalidOperationException: unknown error: cannot find Chrome
binary (Driver info: chromedriver=2.12.301325
(962dea43ddd90e7e4224a03fa3c36a421281abb7),platform=Windows NT 6.2
x86_64) at
OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
errorResponse) 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()
Following is the my code segment where the exception is thrown:
The chromedriver.exe is inside C:\inetpub\vhosts\mywebsitename.com\httpdocs\bin
Code:
driver = new ChromeDriver(#"C:\inetpub\vhosts\mywebsitename.com\httpdocs");
driver.Url = "https://www.google.co.in/";
Can anyone suggest me , where is the problem, B'coz chromedriver.exe running process is their in task bar when the program execution starts.
Here is the working java code to launch chrome and open the url entered :
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "Path_to_Chrome.exe\\chromedriver.exe");
driver= new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://facebook.com/");
driver.close();
}
I hope this will work

Issues with handling SSL certiicates on Chrome, IE and Opera

As the title says it, I'm struggling with handling the SSL certificates in Chrome, IE and Opera browsers.
What I'm doing:
ChromeOptions opt = new ChromeOptions();
opt.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true);
IWebDriver driver = new ChromeDriver(opt);
driver.Navigate().GoToUrl("https://localhost");
What I'm getting:
Result StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
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 ... (project name and path here)
Result Message: Initialization method <Project and test method name here> threw exception. System.InvalidOperationException: System.InvalidOperationException: unknown error: cannot parse capability: chromeOptions
from unknown error: unrecognized chrome option: acceptSslCerts
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64).
Similarly, I'm getting the same thing for Opera browser by using OperaOptions and OperaDriver classes:
System.InvalidOperationException: unknown error: cannot parse capability: operaOptions
from unknown error: unrecognized chrome option: acceptSslCerts
And for Internet Explorer browser, by using InternetExplorerOptions and InternetExplorerDriver classes, I'm not getting any errors, but the SSL Certificate is not handled properly.
Any help is appreciated.
Few things I am assuming you've already set chromedriver executable property. I would suggest you to try this out as below:
DesiredCapabilities capability = DesiredCapabilities.chrome();
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new ChromeDriver(capability);

"Unexpected error. ok" in Selenium Webdriver

I have seen this error first time and I never had this before can anybody tell me what is this error about?
the only new thing what I have done is add this line of code:
IWebDriver driver = new FirefoxDriver();
driver.Manage().Timeouts.SetPageLoadTimeout(TimeSpan.FromSeconds(2));
error:
Unexpected error. ok
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 1002
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 809
at OpenQA.Selenium.Remote.RemoteWebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 709
at OpenQA.Selenium.Remote.RemoteWebElement.Execute(String commandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebElement.cs:line 803
at OpenQA.Selenium.Remote.RemoteWebElement.Click() in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebElement.cs:line 329