WebDriver IO fails to create chrome browser sessions when using in Botium - selenium

I have installed Botium-Binding and prepared my machine to have installed with selenium-standalone server as per the documentation in https://github.com/codeforequity-at/botium-connector-webdriverio.
Once everything is setup i have added below capabilites to the botium.json file in samples/custom scripts folder.
"WEBDRIVERIO_OPTIONS": {
"capabilities": {
"browserName": "chrome",
}
}
Then i have run the command npm install && npm run mocha to trigger the runner.
All i could see is that the Webdriver session is being created and terminated with the error below:
WebdriverIO Plugin Sample
Starting ChromeDriver 92.0.4515.107 (87a818b10553a07434ea9e2b6dccf3cbe7895134-refs/branch-heads/4515#{#1634}) on port 44325
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
1) "before each" hook for "contractcancellation"
0 passing (9s)
1 failing
1) WebdriverIO Plugin Sample
"before each" hook for "contractcancellation":
Error: WebDriver error on startup: Failed to create session.
Make sure to connect to valid hostname:port or the port is not in use.
If you use a grid server
Make sure to add vendor prefix like "goog:", "appium:", "moz:", etc to non W3C capabilities.
See more https://www.w3.org/TR/webdriver/#capabilities
tried adding Hostname, port, platform to the capabilities but of no use. Looking for some help on this to get me unblocked.

You have to follow the instructions to install a chromedriver version that matches your Chrome version (as pcalkins wrote above).
It this doesnt help I recommend to enable verbose logging to get more insights on whats happening. You may post the log output here for further investigation.

Related

Getting Chromedriver logs from standalone Selenium Chrome instance

Summary: How do I extract Chromedriver logs when running Selenium standalone Chrome instance? I.e. interacting via Selenium API commonly on port 4444.
Details:
We are using Protractor to connect to a container running the Docker image selenium/standalone-chrome Selenium "grid". Connection info is specified via the HUB_PORT_4444_TCP_ADDR environment variable. The connection URL ends up being http://localhost:4444/wd/hub. This works fine and our tests are running successfully in Jenkins.
For completeness I'd like to extract the Chromedriver logs and attach them to the build in case we need more info for debugging test failues. How can that be done?
This question seemed like a close match but they are running Chromedriver directly. I need to ask Selenium to provide them somehow.
Log properties of standalone chrome container can be configured using JAVA_OPTS.
You can add JAVA_OPTS environment variable to standalone chrome container
name: JAVA_OPTS
value: "-Dwebdriver.chrome.logfile=<Path to log file, with file name>"
We had a shared volume mounted, and gave path to that folder for putting log file.
Used yaml file for creating container template so used in above mentioned way.
If you are using CLI to launch container, same can be passed through CLI too.

Python Selenium Remote Webdriver(Chrome Webdriver via Selenium Grid), created but does not open browser

I have the following setup:
A Selenium server hub running at "http://localhost:hubPortNum" (a service with the Jar file selenium-server-standalone-3.141.5.jar with parameter -role hub).
A Selenium Node at running "http://localhost:nodePortNum' (the service with Jar file with parameters: -Dwebdriver.chrome.driver=ChromeWebdriverPath -role node -port :nodePortNum).
I checked the URL for the hub and node instances to be sure they are working.
Whenever I try to create Remote Webdriver via Python script:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
desiredCapabilities = DesiredCapabilities.CHROME.copy()
chromeOptionsRemote = webdriver.ChromeOptions()
chromeOptionsRemote.add_argument("--start-maximized")
chromeOptionsRemote.add_argument("--disable-session-crashed-bubble")
initRemoteDriver = webdriver.Remote(options=chromeOptionsRemote, command_executor='http://127.0.0.1:<nodePortNum>/wd/hub', desired_capabilities=desiredCapabilities)
print(initRemoteDriver.current_url)
The last line does print the current URL(which is "data:,"), that means Webdriver is created.
But the browser does not open on my local machine, that is it is running in the background and I don't know how to make it visible although it has worked in the past.
The troubleshooting steps I have made:
Reinstall latest selenium python package.
Re-Download latest Selenium server jar file.
Updating chrome.
adding chromeOptionsRemote.add_argument("--no-sandbox")
Making sure local Webdriver does open:
That is the line:
self.localDriver = webdriver.Chrome(options=chromeOptionsLocal,
desired_capabilities=desiredCapabilities)
does open the browser locally(the Chromedriver is in the path).
After I made these troubleshooting steps, I have tried the same configuration on a remote server and got the same result(browser not visible), so I think this is probably by design.
what configuration should I create for the browser to be visible?
Any help would be appreciated.
I was running the jar file by Always-Up: https://www.coretechnologies.com/products/AlwaysUp/
The problem was related to session 0 isolation: https://stackoverflow.com/a/26752251/2710840
in order to not run the application under session 0, I have enabled the Autologon feature:
defined the user under the application run as my user:
and executed the application from the context menu with the option to: "restart in this session"

How to run Protractor test when spec is remote

Here's the situation:
machineA has Protractor, Selenium, WebDriver, etc. installed.
machineB has all source code including tests and server running source code, but no Protractor, Selenium, etc
environment is Linux on both machines
How can I run the Protractor command on machineA so that it points to the spec on machineB?
ie. How to get a local Protractor command to point to a remote spec?
You need to provide seleniumAddress in your config file and make sure directConnect option is commented or value should be false.
Start webdriver on machineA through webdriver-manager start
exports.config = {
baseUrl: 'http://example.com/',
seleniumAddress: 'https://<machineA IP addess>:4444/wd/hub',
//directConnect:true,
...
}

Protractor on offline machine

Angular 4 cli project
We have private network with private npm repository.
(There is no connection to the internet).
so after all modules are downloaded I want to run e2e tests.
Protractor use webdriver-manager to download the latest chrome driver.
but he can't download the driver so I get this error :
etaddrinfo ENOTFOUND chromedriver.storage.googleapis.com chromedriver.storage.googleapis.com:443
I tried to download the driver manually, and inside the protactor-config :
{
chromeDriver: "../../chromedriver.exe", // I also tried with "./chromedriver_2.30.exe"
....
}
(I don't know if the chromedriver is relative path to the protractor.config or to the webdriver-manager module inside protractor)
But I keep getting this error, how can I treat this error without an internet connection at all?
btw, something to consider, we develop on windows, but how can our ci/cd server (linux) will get a driver suitable for linux??
I had a similar issue. After trying different approaches like manually copying the driver or changing the protractor module, I found that the best workaround is to install a local Web server and provide the required driver for download through that local server. This solution worked and is also useful to provide other files (e.g. files that are directly downloaded during "npm install"). Steps are listed below.
Install Apache on the offline system or any other system accessible to that offline system.
On an online system, download the driver from (https://chromedriver.storage.googleapis.com/ - the site that the update command tries to access). Accessing this site in the browser displays a file (download.xml) that lists different versions of the web driver for different platforms. You can download the required version by appending the "Key" shown in that file to the end of the URL e.g. (https://chromedriver.storage.googleapis.com/2.33/chromedriver_win32.zip) to download version 2.33 of the chrome driver for windows. I tried newer versions but found that 2.33 worked on Win 10 (64 bit)/Chrome 61.
Manually copy the downloaded zip file to the offline system in the Apache htdocs folder using the same path as in the key e.g. (c:\\htdocs\2.33\chromedriver_win32.zip)
Make a download.xml file similar to the one on the actual site (https://chromedriver.storage.googleapis.com) but only list one entry for the driver version that you need.
Modify your Apache config file (conf\httpd.conf) to make download.xml as DirectoryIndex file
Run Apache (bin\httpd.exe)
Change your windows hosts file to add an entry to map (chromedriver.storage.googleapis.com) to the IP of the system where Apache is running.
Run "ng e2e". "webdriver-manager update" will download this local driver and tests will continue.
I had a similar issue. Found this answer with googling and I tried it. Seems to work.
With recent changes in protractor you can use:
ng e2e --webdriver-update=false
I had the same problems and my solution it's not the best, but it works.
Locally:
run webdriver-manager update in my example I had to run it with -ignore_ssl
go to the \node_modules\protractor\node_modules\webdriver-manager\selenium\and copy all files (except update-config.json) to some root folder
commit and push changes (I know, we are pushing web drivers to the repo which is not the best solution)
On Offline Machine - TFS in my case
run npm install
copy webdrivers back to the folder node_modules\protractor\node_modules\webdriver-manager\selenium\
I use Angular CLI so run ng e2e --no-webdriver-update
The best way is to put it in your angular.json:
"e2e": {
"builder": "#angular-devkit/build-angular:protractor",
"options": {
"webdriverUpdate": false,
"protractorConfig": "e2e/protractor.conf.ts",
"devServerTarget": "myproject:serve"
},

Web Driver Curl Exception

Trying to use Codeception Web Driver and Selenium to emulate ajax through an acceptance test. I was using PhpBrowser but when I was having issues with Ajax my friend suggested WebDriver.
After enabling it and downloading the selenium (and running it) I get the following error.
[WebDriverCurlException]
Curl error thrown for http POST to http://127.0.0.1:4444/wd/hub/session
with params: {"desiredCapabilities":{"browserName":"googlechrome"}}
Failed to connect to 127.0.0.1 port 4444: Connection Refused
I made sure I was running selenium on port 4444.
java -jar selenium-server.jar -port 4444
acceptance.suite.yml below
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
- REST
config:
WebDriver:
url: 'http://life1605.dev'
browser: googlechrome
REST:
url: 'http://life1605.dev'
I had the same problem, with the exact same error message. For some strange reason, it looked like starting the selenium server from command line did not work.
My solution turned out to be manually opening the selenium server through Windows Explorer, right click on the file, choose Open with -> Java Platform SE Binary.
Took me almost 3 hours to figure it out, so I hope this helps somebody.
I had this problem and it turned out a new version of Firefox was incompatible with the addon that Selenium uses to communicate with Firefox.
When you start your tests you should see the new Firefox window appear, and have 30 seconds or so before it goes away again. Within this time, if you type about:addons into the URL field and then click on "Extensions", you should see the "Firefox WebDriver" addon there, and it should be enabled.
For me it was disabled as it was incompatible with the latest Firefox version. So the solution in this case was to either downgrade Firefox or wait for an updated Selenium.
Note that the addon is only installed in the Firefox instance under test, so you won't see it when you use Firefox outside of Selenium.
I had this same problem, I forgot to run phantom.js before trying to do any browser tests. I ran phantomjs and it worked.
I had this problem, and then I remembered that I need to run Xvfb -ac :0 -screen 0 1280x1024x16 & after every Homestead reload (before running Dusk tests).
Then Dusk works instead of saying:
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown
for http POST to /session with params:
{"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}
Operation timed out after 30000 milliseconds with 0 bytes received
See https://stackoverflow.com/a/42630737/470749