protractor web-driver with selenium on linux - node.js

I have the following setup:
protractor running from a windows vm using a stand alone selenium server on a linux headless box.
The idea was to have chrome installed on my windows vm and to have protractor use this chrome install to run the tests via the selenium on the linux box. I start the selenium server on the linuxx box using webdriver-manager start.
When I run the tests from the VM I get the folloiwng error
Caused by: org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 2.6.32-431.29.2.el6.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 134 milliseconds
Build info: version: '2.45.0',java.version: '1.7.0_79'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:139)
... 14 more
10:39:09.119 WARN - Exception: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 2.6.32-431.29.2.el6.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 134 milliseconds
java.version: '1.7.0_79'
Driver info: org.openqa.selenium.chrome.ChromeDriver
In my protractor conf I it configured to use the selenium standalone server by specifying the selenium url.
Any ideas how to resolve this and get the browser to be opened on my windows vm rather than the linux box looking for the chrome binary.
Thanks

Related

Selenium Error: "org.openqa.selenium.WebDriverException: Error loading page"

I keep running into this error when using a tool that attempts to load a locally-saved web page via Selenium, gekodriver, and firefox.
Versions utilized:
Selenium: 3.0.1
Gekodriver: 13.0
Firefox: 46.0
My constraints are that I have to use selenium 3.0.1, but the other dependencies can be altered. Has anybody run into this issue before?
1676503488636 geckodriver INFO Listening on 127.0.0.1:12651
Feb 15, 2023 3:24:48 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1676503488712 mozprofile::profile INFO Using profile path /tmp/rust_mozprofile.gQ6hEnrnMxIC
1676503488713 geckodriver::marionette INFO Starting browser /home/robert/firefox/firefox-bin
1676503488714 geckodriver::marionette INFO Connecting to Marionette on localhost:36313
1676503489262 Marionette INFO Listening on port 36313
Feb 15, 2023 3:24:50 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
org.openqa.selenium.WebDriverException: Error loading page
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'robert-XPS-8700', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-58-generic', java.version: '1.8.0_202'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20160421124000, version=, platform=LINUX, proxy={}, specificationLevel=1, acceptSslCerts=false, browserVersion=46.0, platformVersion=5.15.0-58-generic, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=Firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=Linux, device=desktop}]
Session ID: 918b2a1b-0b33-4acf-ae5a-8545c55ad0d9
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:322)
at shef.main.RLGExtractor.extract(RLGExtractor.java:105)
at shef.main.Tool.runFaultDetector(Tool.java:185)
at shef.main.Tool.<init>(Tool.java:136)
at shef.main.Tool.main(Tool.java:417)
As per the geckodriver specifications Selenium users must update to version 3.11 or later to use geckodriver like other clients that follow the W3C WebDriver specification and are also supported.
Additionally, support for GeckoDriver is best in Firefox 57 and greater, however the more recent the Firefox version, the better the experience as they contain more bug fixes and the recent features while some features will only be available in the latest Firefox Nightly with GeckoDriver.
This usecase
If you are working with the legacy Firefox releases (i.e. till Firefox 47.x) geckodriver still works but you have to explicitly set the property "marionette" to false as follows:
cap = DesiredCapabilities().FIREFOX
cap["marionette"] = False

Protractor : E/launcher - Error: WebDriverError: Timed out waiting for driver server to start

Am facing 'Unable to start a WebDriver session' when trying to execute protractor tests through chrome.After trying out all the below options, am posting here for a solution :
Triggered the run with latest and earlier versions of chrome browser and driver
Manually placed chromedriver in webdriver-manager/selenium path.
3.added chromeOptions: {
binary: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"}
Please let me know how to resolve this issue .Current O.S is Catalina : 10.15.7.
Below is the error :
$ protractor config.js
[13:26:19] I/launcher - Running 1 instances of WebDriver
[13:26:19] I/local - Starting selenium standalone server...
[13:26:19] I/local - Selenium standalone server started at http://192.168.1.4:53615/wd/hub
[13:26:40] E/runner - Unable to start a WebDriver session.
[13:26:40] E/launcher - Error: WebDriverError: Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.7', java.version: '11.0.4'
Driver info: driver.version: unknown
update webdriver by using following in terminal:
./node_modules/protractor/bin/webdriver-manager update
It worked after removing node modules, uninstalling protractor , npm and reinstalling everything.

Selenium in "HeadLess" mode "Runtime.executionContextCreated has invalid 'context'" on Vagrant [duplicate]

I'm trying to get started using selenium and have downloaded a chrome driver and put into my classpath. I'm just trying to get the title right now to see if I can get it to work. Code currently looks like this:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Flows {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "/Users/mn/Desktop/project/turv/src/main/chromedriver");
WebDriver driver = new ChromeDriver();
String baseUrl = "http://google.dk/";
driver.get(baseUrl);
System.out.println(driver.getTitle());
driver.close();
}
}
I expected my output to be something along the lines of "Google", but I get this error instead:
Connected to the target VM, address: '127.0.0.1:55299', transport: 'socket'
Starting ChromeDriver (v2.8.241036) on port 2571
[warn] kq_init: detected broken kqueue; not using.: Undefined error: 0
May 07, 2018 12:12:35 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Disconnected from the target VM, address: '127.0.0.1:55299', transport: 'socket'
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"11895A1B77AC560388AA2919259E1422","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=66.0.3359.139)
(Driver info: chromedriver=2.8.241036,platform=Mac OS X 10.13.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'cetreas-MBP', ip: 'fe80:0:0:0:c9e:2c67:1d27:4e0b%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.3', java.version: '1.8.0_161'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptSslCerts: true, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {userDataDir: /var/folders/s7/lv2wt4t15cn...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, javascriptEnabled: true, locationContextEnabled: true, nativeEvents: true, platform: MAC, platformName: MAC, rotatable: false, takesHeapSnapshot: true, takesScreenshot: true, version: 66.0.3359.139, webStorageEnabled: true}
Session ID: ca1f4ba131e73c3d01058bec2b976d22
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:273)
at com.cetrea.flows.Flows.main(Flows.java:15)
I cant really figure out what the error is trying to tell me. Is it because I'm asking for the title before it has fully loaded the site maybe? Do I need to add some kind of waitforit command before the getTitle() ?
This error message...
org.openqa.selenium.WebDriverException: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"11895A1B77AC560388AA2919259E1422","isDefault":true},"id":1,"name":"","origin":"://"}
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your main issue is the version compatibility between the binaries you are using as follows :
You are using chromedriver=2.8 which is pretty ancient.
You are using chrome=66.0
Release Notes of ChromeDriver v2.38 clearly mentions the following :
Supports Chrome v65-67
So there is a clear mismatch between ChromeDriver version (v2.8) and the Chrome Browser version (v66.0)
Solution
Upgrade ChromeDriver to current ChromeDriver v2.38 level.
Keep Chrome version at Chrome v66.x levels. (as per ChromeDriver v2.38 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Selenium Standalone Server in Docker - TimeoutException

I tried to execute a WebDriver 3.5 based test with ChromeDriver 2.31 in a Selenium Docker container.
I used this command to start necessary container:
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:3.5.3-astatine
I use RemoteWebDriver to execute testsuite on remote host. It fails with following log:
org.openqa.selenium.TimeoutException: timeout (Session info:
chrome=61.0.3163.79) (Driver info: chromedriver=2.31.488763
, platform=Linux
4.10.0-33-generic x86_64) (WARNING: The server did not provide any stacktrace information) Build info: version: '3.5.2', revision: '10229a9', time:
'2017-08-21T17:29:55.15Z' Driver info:
org.openqa.selenium.remote.RemoteWebDriver Capabilities
[{applicationCacheEnabled=false, rotatable=false,
mobileEmulationEnabled=false, networkConnectionEnabled=false,
chrome={chromedriverVersion=2.31.488763,
userDataDir=/tmp/.org.chromium.Chromium.IAkqFG},
takesHeapSnapshot=true, pageLoadStrategy=normal,
unhandledPromptBehavior=, databaseEnabled=false, handlesAlerts=true,
hasTouchScreen=false, version=61.0.3163.79, platform=LINUX,
browserConnectionEnabled=false, nativeEvents=true,
acceptSslCerts=true, locationContextEnabled=true,
webStorageEnabled=true, browserName=chrome, takesScreenshot=true,
javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true,
unexpectedAlertBehaviour=}]
I checked web panel on http://:4444/wd/hub/static/resource/hub.html and found, there is a Chrome session, but when I try to take a screenshot I get a blank screen. The test fails when trying to access to this site.
The site uses invalid SSL, so HTTPS connection is insecure, but I use commands below to ignore certificate errors. It is working on local machine.
options.addArguments("--ignore-certificate-errors");
caps.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true);

WebDriverJS with PhantomJS works on OSX, but not on Linux

I'm using a combination of:
Selenium Standalone - https://github.com/vvo/selenium-standalone
WebDriverJS - https://github.com/webdriverio/webdriverio
Medium's PhantomJS NPM wrapper - https://github.com/Medium/phantomjs
Each component works fine separately, and when I run:
var client = webdriverjs.remote({
desiredCapabilities: {
browserName: 'phantomjs',
'phantomjs.binary.path': '/path-to/node_modules/phantomjs/bin/phantomjs'
},
logLevel: 'silent'
});
client.init();
It works fine on OSX/Mac, but on our CI Linux server (Ubuntu), I get the following error message;
PhantomJS is launching GhostDriver...
Unable to open file '/path/to/phantomjsdriver.log'
Before the ineveitable Java stacktrace...
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:176)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:112)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:89)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:110)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:57)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:112)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:173)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:200)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:128)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
&
Driver info: driver.version: PhantomJSDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:590)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:127)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:140)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:110)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:99)
... 14 more
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
I suspect a permissions issue, but wondered if anyone has run into this problem before.
At the very least, it would be great to work out exactly why this is working on Mac.
This file - phantomjsdriver.log - Can only be created by a user with file write permissions.
Executing the program as 'root' fixed the issue.

Resources