Chrome not reachable error message selenium webdriver for chromium application - selenium

I am automating a chromium application using selenium webdriver. These are my configuration settings:
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--url=application url");
chromeOptions.setBinary("application exe file");
chromeOptions.addArguments("--ignore-certificate-errors");
chromeOptions.addArguments("--remote-debugging-port=8000"); WebDriver
driver = new ChromeDriver(chromeOptions);
This code launches the chromium application successfully. I've confirmed that port 8000 is listening and able to get chromium application object on chrome browser.
But I am getting the exception below:
Starting ChromeDriver 2.16.333243
(0bfa1d3575fc1044244f21ddb82bf870944ef961) on port 18739 Only local
connections are allowed. FAILED CONFIGURATION: #BeforeMethod setUp
org.openqa.selenium.WebDriverException: chrome not reachable

Related

Selenium Firefox Headless Connect Remote Debugger

I am running a headless firefox browser with Selenium. If I run it in GUI mode then it works fine but when I run it in headless mode then I get an error about element being obstructed.
I really need a way to connect the Firefox remote debugger so I can see what is happening in the headless browser.
How do I enable remote debugging in selenium headless browser?
You can debug marionette Gecko Driver by enabling trace logs and change the log level in order to get trace logs:
You can use FirefoxOptions in Selenium Java client to change the log level
FirefoxOptions options = new FirefoxOptions();
options.setLogLevel(FirefoxDriverLogLevel.TRACE);
WebDriver driver = new FirefoxDriver(options);
For more information have a look at Firefox Source docs. More reading about debugging is here

Why is Selenium webdriver is not opening webpage?

Hi i am trying to connect to remote webdriver on browserstack using Selenium but whenever the page loads in Chrome and Firefox i get a security message (see images below).
my URL is starting with https:// (when i manually open the browser i have to accept the certificates and continue before the webpage loads)
i have added this line to my code but it does not seem to make any difference:
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capability.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION, "true");
capability.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
NOTE: This issue only occurs then the tests are run on the GoCD pipeline. when running on intellij it all works fine
error:
org.openqa.selenium.WebDriverException: Reached error page: about:neterror?e=nssFailure2&u=https%3A//transport....
in chrome i see this:
and in firefox i get a similar message:
Can you try adding something as below and test:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("ignore-certificate-errors");
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
options.addArguments("--test-type");
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("disable-gpu");
chromeOptions.AddArguments("window-size=1980,1080");
Driver = new ChromeDriver(chromeOptions);
i have found the problem for anyones future reference.
This is because DNS requests were not forwarded for our host name on GocD.

UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server with Selenium Grid

Error in opening new driver window:
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.
server log:
Forwarding newSession on session null to remote
I am running following code on linux:
driver= new RemoteWebDriver((new URL( "http://"+ip+":5555/wd/hub")), capability);
My hub-node already up and running. Then why i am getting this error.
This error message...
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.
and the server log...
Forwarding newSession on session null to remote
...implies that the Selenium Grid Hub / Selenium Grid Node wasn't properly initiated/started. As a result a null session was forwarded to the RemoteWebDriver.
Some more information regarding the versions of the binaries which you have used interms of Selenium server/client, WebDriver variant /version and WebBrowser variant /version and the commands you have used to initiate the Selenium Grid Hub / Selenium Grid Node would have helped us to debug your issue in a easier way.
However this issue can happen due to multiple factors as follows:
You are using the uri 5555/wd/hub, so ensure that Selenium Grid Hub is initiated on port 5555.
You may opt to replace the capability argument with an instance of Options class as follows:
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("browser", "chrome");
//seting the required capabilities
ChromeOptions options = new ChromeOptions();
options.merge(caps);
WebDriver driver = new RemoteWebDriver((new URL( "http://"+ip+":5555/wd/hub")), options);
You can find a relevant discussion in Remote WebDriver UnreachableBrowserException: Could not start a new session
This issue is frequently observed with GeckoDriver/Selenium/Mozilla due to version mismatch of the binaries you are using. As a thumb rule always follow the configuration matrix from the GeckoDriver, Selenium and Firefox Browser compatibility chart
You can find a relevant discussion in WebDriverException: Message: newSession with GeckoDriver Firefox v65 and Selenium through Python 3.7

How to handle SSL certificate for Firefox, Chrome and IE browsers using Selenium 3.4.0 standalone

My application has both http and https ssl certificate. To handle https link using Selenium 3.4.0 I have used following code for firefox. Firefox browser is opening, but it is showing 'Secure Connection Failed'
System.setProperty("webdriver.gecko.driver","C:\\Users\\vidhya.r\\Desktop\\Automation\\Jars\\geckodriver.exe");
FirefoxProfile pro = new FirefoxProfile();
pro.setAcceptUntrustedCertificates(true);
WebDriver driver = new FirefoxDriver(pro);
driver.get("https://192.168.8.115:7077/final/#!");
Below solution will definitely work for your chrome browser.
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.addArguments("--ignore-certificate-errors");
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")+"/Drivers/chromedriver.exe");
driver = new ChromeDriver(options);
driver.get(applicationURL);
driver.manage().window().maximize();

DesiredCapabilities 'Chrome' > doesn't work with 'Selenium Grid'

DesiredCapabilities 'Chrome' > doesn't work with 'Selenium Grid.
I have a hub setup correctly and a node
however when trying to point Chrome browser to one of the nodes it doesn't work.
Current code:
case "chrome":
if (null == webdriver) {
System.setProperty("webdriver.chrome.driver", Constant.CHROME_DRIVER_DIRECTORY);
DesiredCapabilities capability = DesiredCapabilities.chrome();
capability.setBrowserName("chrome");
capability.setVersion("55.0.2883.87 m");
capability.setPlatform(Platform.WINDOWS);
webdriver = new RemoteWebDriver(new URL("http://172.16.1.48:5555/wd/hub"),capability);
}
break;
Exception:
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, version=55.0.2883.87 m, platform=WINDOWS}], required capabilities = Capabilities [{}]
Couple of things :
On the node side, please ensure that the chromedriver (for chrome browser), geckodriver(for firefox browser) and IEDriverServer(for IE) are all available in the PATH variable and can be invoked by just opening up a command prompt and typing their names.
When you do DesiredCapabilities capability = DesiredCapabilities.chrome(); it automatically sets the browser name appropriately. So you don't need to set it again via capability.setBrowserName("chrome"); (So you can remove it off).
Unless and until you have explicitly set a browser version at your node level via the nodeConfig json file, please remove capability.setVersion("55.0.2883.87 m"); because this causes your test to ask for a node that can support chrome 55 version, but if you don't specify the same versioning at your node, your grid will turn down your new session request stating it cannot find the required desired capabilities.
Going by your screenshot it looks like your hub is running on localhost listening to the port 4444 but your code shows as if you are trying to connect to the node directly. So please change webdriver = new RemoteWebDriver(new URL("http://172.16.1.48:5555/wd/hub"),capability); to `webdriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),capability);
Once you have taken care of these items, your issue should get fixed.