Unable to start Selenium server using WebdriverIO on Windows - selenium

I'm following instructions from http://webdriver.io/guide.html
The fourth step mentions this:
java -jar -Dwebdriver.gecko.driver=./geckodriver selenium-server-standalone-3.5.3.jar
After downloading and installing Selenium and WebdriverIO for Windows, I provided the environmental path for all the drivers and executables in System Properties.
I seem to be hitting this issue after I try to execute the aforementioned command through Powershell.
PS C:\webdriverio-test> java -jar -Dwebdriver.gecko.driver=".\geckodriver.exe" .\selenium-server-standalone-3.12.0.jar
Error: Unable to access jarfile .gecko.driver=.\geckodriver.exe
PS C:\webdriverio-test> java -jar -Dwebdriver.gecko.driver=geckodriver.exe .\selenium-server-standalone-3.12.0.jar
Error: Unable to access jarfile .gecko.driver=geckodriver.exe
PS C:\webdriverio-test> java -jar -Dwebdriver.gecko.driver=geckodriver .\selenium-server-standalone-3.12.0.jar
Error: Unable to access jarfile .gecko.driver=geckodriver
PS C:\webdriverio-test> java -jar -Dwebdriver.gecko.driver=./geckodriver .\selenium-server-standalone-3.12.0.jar
Error: Unable to access jarfile .gecko.driver=./geckodriver
If I try running standalone Selenium server without using geckodriver, it works well. However, the main intention is to make it work using geckodriver and something seems to be going wrong here.
It just worked once when I installed it yesterday, but it doesn't seem to be working now. Any pointers as to how to make this work, would be appreciable.
Contents of the directory:
PS C:\webdriverio-test> ls
Directory: C:\webdriverio-test
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 5/31/2018 2:41 PM node_modules
d----- 5/31/2018 10:54 AM nssm-2.24
d----- 5/31/2018 10:40 AM test
-a---- 4/8/2018 12:49 PM 9684296 geckodriver.exe
-a---- 5/31/2018 2:41 PM 50430 package-lock.json
-a---- 5/30/2018 3:37 PM 23556263 selenium-server-standalone-3.12.0.jar
-a---- 5/30/2018 4:16 PM 383 test.js
-a---- 5/31/2018 9:31 AM 471 test_2.js
-a---- 5/31/2018 10:51 AM 9875 wdio.conf.js
Thanks in advance.

The jar file must follow the -jar, noting allowed to insert between -jar and the jar file
Execute in Windows CMD:
java -Dwebdriver.gecko.driver=./geckodriver.exe -jar ./selenium-server-standalone-3.12.0.jar
Execute in Windows PowerShell:
java "-Dwebdriver.chrome.driver=chromedriver_2.38.exe" -jar .\selenium-server-standalone-3.12.0.jar
For PowerShell, if the name of -Dname=value includes ., you must use double quote to around the -Dname=value
Note: please use JDK 8 or above.

Related

Can't backup db: libpq.so.5: cannot open shared object file: No such file or directory

Given:
Linux Mint 20.3
DB Client: DBeaver 22.1.4
I try to backup my Postgresql's db (my_db) by DBeaver.
But I get error:
/run/user/1000/doc/65139af1/bin/pg_dump --verbose --host=localhost --port=5432 --username=postgres --format=p --file /home/my_user/dev/BACKUP/my_db_local/dump-my_db-202211161718.sql -n public my_db
Task 'PostgreSQL dump' started at Wed Nov 16 17:18:29 EET 2022
/run/user/1000/doc/65139af1/bin/pg_dump: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory
Task 'PostgreSQL dump' finished at Wed Nov 16 17:18:29 EET 2022
2022-11-16 17:18:29.831 - IO error: Process failed (exit code = 127). See error log.
2022-11-16 17:18:29.832 - java.io.IOException: Process failed (exit code = 127). See error log.
at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.validateErrorCode(AbstractNativeToolHandler.java:242)
at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.executeProcess(AbstractNativeToolHandler.java:223)
at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.doExecute(AbstractNativeToolHandler.java:262)
at org.jkiss.dbeaver.tasks.nativetool.AbstractNativeToolHandler.lambda$0(AbstractNativeToolHandler.java:83)
at org.jkiss.dbeaver.runtime.RunnableContextDelegate.lambda$0(RunnableContextDelegate.java:39)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Check if you have installed lib libpq.so.5 running the command:
dconfig -p | grep libpq.so.5
If installed, something similar to this will appear....
libpq.so.5 (libc6,x86-64) => /lib/x86_64-linux-gnu/libpq.so.5
Make sure you are not using the flatpak version, I had the same problem with this version, if you are using it, uninstall and download the .deb package and install from there.
https://dbeaver.io/download/

Jenkins run causes Selenium tests to fail with org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally?

I'm running Selenium tests for Chrome through Jenkins pipeline on CentOs machine. When ran, it gives following error -
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
[testng] (unknown error: DevToolsActivePort file doesn't exist)
[testng] (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
However if I run same tests with same command(which is used through Jenkins pipeline) from that machine locally, it succeeds.
For the same, I went through link1, link2, link3 and other answers. From those answers, only following helped -
chrome_options.add_argument('--headless')
But this run tests with chrome in headless mode which is not my intention.
In my case, having matching Chrome browser and chromedriver version did not help, also Chrome has executable permission for all.
Note: I've my CentOs machine display enabled
Could you please help to understand what is causing this failure? Also please help with what code and/or machine level changes I've to make for its success.
EDIT:
In case, this helps to get more info.
ls | grep 'chrome' under /usr/bin gave following result -
lrwxrwxrwx 1 root root 31 Jan 20 12:29 google-chrome -> /etc/alternatives/google-chrome
lrwxrwxrwx 1 root root 32 Jan 20 12:29 google-chrome-stable -> /opt/google/chrome/google-chrome
Do you run chromedriver locally on a linux machine? What version of CentOS are you using? If you haven't already you need to install the correct chromedriver for linux. As far as I know if you want to run via Jenkins you have to run in headless mode. But I may be wrong. Below is another post that can help:
Steps to Install and run headless chrome browser on centos 6.5 using chrome driver
Below are my own settings for chrome options:
options.addArguments("--headless");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--allow-insecure-localhost");
options.addArguments("--window-size=1920,1080");
options.addArguments("start-maximized");
options.addArguments("enable-automation");
options.addArguments("--disable-infobars");
options.addArguments("--disable-browser-side-navigation");
options.addArguments("--disable-gpu");
options.addArguments("--no-sandbox");
options.addArguments("--force-device-scale-factor=1");

Selenium with Firefox-ESR in Alpine Docker image

I'm using Selenium for testing from Java code, it's started automatically with maven, when I run mvn verify it uses gecko-driver to start new firefox instance for selenium:
final FirefoxOptions opts = new FirefoxOptions();
if (HEADLESS_MODE) {
opts.addArguments(ARG_HEADLESS);
}
return new FirefoxDriver(opts);
It's working fine on my machine (and on machines of other developers) in both modes "headless" and normal. Now I'm trying to run Selenium tests with CI builds in Alpine Linux Docker container. When I tried to run it as-is, I've got an error:
mozrunner::runner INFO Running command: "/usr/bin/firefox"
"-marionette" "--headless" "-foreground" "-no-remote"
"-profile" "/tmp/rust_mozprofile.pW1sbkcv98QN"
Error: GDK_BACKEND does not match available displays.
Then I installed all suggested tools (dbus and xvfb) from this post and started it before running tests:
apk add xvfb dbus
dbus-uuidgen > /etc/machine-id
export DISPLAY=:99
Xvfb $DISPLAY -ac &
mvn verify
but now Selenium tests are hadning for about 10 seconds and failing with error
1565433736375 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "--headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.1ZMsJ0Hy95V0"
1565433738424 Marionette INFO Listening on port 2828
!!! [Child][MessageChannel] Error: (msgtype=0x3E0003,name=PCompositable::Msg_Destroy) Channel error: cannot send/recv
[Child 2191] ###!!! ABORT: Aborting on channel error.: file /home/buildozer/aports/community/firefox-esr/src/firefox-52.8.1esr/ipc/glue/MessageChannel.cpp, line 2152
[Child 2191] ###!!! ABORT: Aborting on channel error.: file /home/buildozer/aports/community/firefox-esr/src/firefox-52.8.1esr/ipc/glue/MessageChannel.cpp, line 2152
!!! [Child][MessageChannel] Error: (msgtype=0x3E0003,name=PCompositable::Msg_Destroy) Channel error: cannot send/recv
It seems I'm doing something wrong here, what is the correct way to run headless Selenium tests in Alpine Linux Docker container? I'd prefer to configure existing Docker image instead of using Selenium images, because the migration will be expensive.
Update:
Selenium version is 3.141.59
Gecko-driver version is v0.24.0-linux64
Firefox-ESR version is: 52.8.1-r0
Update2:
xvfb, dbus and exported DISPLAY are not actually needed to run Firefox in headless mode - just run firefox --headless and it's all.
As per Mozilla --headless flag is not supported in Firefox 52-esr.Headless flag was introduced in version 55 (for Linux) and 56 (Mac/Windows) . Please try on latest Firefox ESR release.

Protractor with Visual Studio Team Services - "Could not find chrome binary"

I've been trying to setup Protractor on Visual Studio Team Services and currently I'm having a build run a .bat file to start my protractor test.
When the build runs, it gives me an error message saying Could not find Chrome binary, and gives me a file location that doesn't exist on my directory.
Error trace-back:
2017-05-25T20:43:49.3521640Z ##[section]Starting: Run script protractor.bat
2017-05-25T20:43:49.3521640Z
===========================================================================
2017-05-25T20:43:49.3521640Z Task : Batch Script
2017-05-25T20:43:49.3521640Z Description : Run a windows cmd or bat script and optionally allow it to change the environment
2017-05-25T20:43:49.3521640Z Version : 1.1.3
2017-05-25T20:43:49.3521640Z Author : Microsoft Corporation
2017-05-25T20:43:49.3521640Z Help : [More Information]
(https://go.microsoft.com/fwlink/?LinkID=613733)
2017-05-25T20:43:49.3521640Z
============================================================================
2017-05-25T20:43:49.3601629Z ##[command]d:\a\1\s\protractor.bat
2017-05-25T20:43:49.3761643Z
2017-05-25T20:43:49.3761643Z d:\a\1\s>cd .\e2e
2017-05-25T20:43:49.3761643Z
2017-05-25T20:43:49.3761643Z d:\a\1\s\E2E>protractor conf.js
2017-05-25T20:43:50.8302366Z [20:43:50] I/direct - Using ChromeDriver directly...
2017-05-25T20:43:50.8342360Z [20:43:50] I/launcher - Running 1 instances of WebDriver
2017-05-25T20:43:50.8342360Z [20:43:50] E/direct - Error code: 135
2017-05-25T20:43:50.8342360Z [20:43:50] E/direct - Error message: Could not find chromedriver at C:\NPM\Modules\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.25.exe
2017-05-25T20:43:50.8342360Z [20:43:50] E/direct - Error: Could not find chromedriver at C:\NPM\Modules\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.25.exe
2017-05-25T20:43:50.8342360Z at Direct.getNewDriver (C:\NPM\Modules\node_modules\protractor\built\driverProviders\direct.js:65:27)
2017-05-25T20:43:50.8342360Z at Runner.createBrowser (C:\NPM\Modules\node_modules\protractor\built\runner.js:197:43)
2017-05-25T20:43:50.8342360Z at C:\NPM\Modules\node_modules\protractor\built\runner.js:276:30
2017-05-25T20:43:50.8342360Z at _fulfilled (C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:834:54)
2017-05-25T20:43:50.8342360Z at self.promiseDispatch.done (C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:863:30)
2017-05-25T20:43:50.8342360Z at Promise.promise.promiseDispatch (C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:796:13)
2017-05-25T20:43:50.8342360Z at C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:556:49
2017-05-25T20:43:50.8342360Z at runSingle (C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:137:13)
2017-05-25T20:43:50.8342360Z at flush (C:\NPM\Modules\node_modules\protractor\node_modules\q\q.js:125:13)
2017-05-25T20:43:50.8342360Z at _combinedTickCallback (internal/process/next_tick.js:67:7)
2017-05-25T20:43:50.8342360Z [20:43:50] E/launcher - Process exited with error code 135
2017-05-25T20:43:50.8552361Z ##[error]Process completed with exit code 135.
2017-05-25T20:43:50.8582364Z ##[section]Finishing: Run script protractor.bat
When I install Chromedriver on the build it installs it to a different file location:
d:\a\1\s\node_modules\chromedriver\lib\chromedriver\chromedriver.exe
The test runs fine locally but doesn't work when I commit it to VSTS.
Is there anyway to make it so that chromedriver is installed in a different file location, or have Selenium look in a different place for chromedriver?
Thanks
Put the relative path to the ChromeDriver executable in conf.js. This is well-documented.
Use webdriver-manager package that comes with protractor - it can download any version of any binary that you want - https://www.npmjs.com/package/webdriver-manager
So it ends up with running webdriver-manager update before starting protractor tests (just make sure that if you are running locally installed protractor - you also update using locally installed webdriver-manager)
First, based on the log, you are using Hosted Build agent that running as service, but the test need to be interact with UI, so you can’t to do Protractor test with Chrome on Hosted Build agent.
You can refer to this way to set up a private build agent on your machine: Deploy an agent on Windows
Secondly, you can refer to these steps to install chromedriver:
Add Npm task (npm command: install; arguments: -g protractor)
Add Command Line task (Tool: webdriver-manager; Arguments: update --versions.chrome 2.25)

cygwin g++ produces no output

I just installed g++ from cygwin, when I try to compile a C++ file I am not getting any executable produced by the compiler, see example below. What's going wrong?
Directory of C:\helloworld
01/02/2011 04:50 PM .
01/02/2011 04:50 PM ..
01/02/2011 04:48 PM 94 helloworld.cpp
1 File(s) 94 bytes
2 Dir(s) 24,658,272,256 bytes free
C:\helloworld>g++-4 helloworld.cpp
C:\helloworld>dir
Volume in drive C is OS
Volume Serial Number is C47B-942D
Directory of C:\helloworld
01/02/2011 04:50 PM .
01/02/2011 04:50 PM ..
01/02/2011 04:48 PM 94 helloworld.cpp
1 File(s) 94 bytes
2 Dir(s) 24,657,747,968 bytes free
C:\helloworld>
For others who end up here with g++ producing no output.
I solved it by running cygcheck -s in the cygwin terminal window. This checks (amongst others) for multiple instances of cygwin1.dll. In my case WinAVR was causing problems, uinstalling did the the trick
This link was also helpful in getting Cygwin to run properly: http://thehacklist.blogspot.nl/2009/04/cygwin-ls-command-not-found.html
The problem seems to be (judging from your C:\ prompt) that you are not running Cygwin. Try double-clicking the Cygwin icon.
You should be able to run any Cygwin program from the DOS prompt since Cygwin is not an operating system like Linux, it is primarily a special DLL that programs link against + tools. However, in this case, I suspect that path issues are preventing g++ from running, either the path to g++ itself or to some libs g++ requires. Cygwin apps are notoriously bad at giving any info when they don't run, and the solution is to run them via strace.
C:\cygwin\bin> strace g++
Then any issues will be shown in a windows dialog box.