Unable to install chromedriver on docker machine using Webdrivermanager - maven

I am using webdrivermanager plugin by Boni Garcia for driver installation. When I use it for execution on my local and everything working fine but I face issues when I try to do the same via Jenkins. Details below:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.3.0</version>
</dependency>
Now when I try to execute the same maven project via Jenkins, I am facing issue. My slave machine is a docker machine.
At first, I tried webdrivermanager to take care of the chrome driver installation and I got error stating that binary not found.
ChromeOptions options = new ChromeOptions();
options.addArguments("headless");
options.addArguments("start-maximized");
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver(options);
Error:
org.openqa.selenium.WebDriverException:
unknown error: cannot find Chrome binary
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729#{#29}),platform=Linux 3.10.0-862.14.4.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Then I tried using driver from within the framework. I saved the chromedriver file in a drivers folder within my framework and then tried to execute it, but still got an error (different error this time though)
ChromeOptions options = new ChromeOptions();
options.addArguments("headless");
options.addArguments("start-maximized");
System.setProperty("webdriver.chrome.driver", "src/test/resources/drivers/chromedriver");
driver = new ChromeDriver(options);
Error:
Running TestSuite
/home/jenkins/workspace/Dental_EIEI_Angular/EIEI Test Jenkins/src/test/resources/drivers/chromedriver: /home/jenkins/workspace/Dental_EIEI_Angular/EIEI Test Jenkins/src/test/resources/drivers/chromedriver: cannot execute binary file
Apr 03, 2019 2:19:23 PM org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 126 (Exit value: 126)

I was running into an issue which was something similar to what you are facing. The WebDriverException : unknown error: cannot find Chrome binary is because your framework is unable to find the chrome binary in jenkins. To set the binary using your code is not fissible because you should know the path of binary file. Instead of getting into that hassle, simply create a docker-compose.yml file to get your infra up and running to execute your tests.
version: "3"
services:
selenium-hub:
image: selenium/hub
container_name: selenium-hub
ports:
- "4444:4444"
environment:
- GRID_BROWSER_TIMEOUT=30
chrome:
image: selenium/node-chrome
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
firefox:
image: selenium/node-firefox
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
then you can use docker-compose up -d to run your infra in detached mode. You also need to do some relevant changes in your code to access the selenium-hub server.
System.setProperty("webdriver.chrome.driver", "src//test//resources//driver//chromedriver");
ChromeOptions cap = new ChromeOptions();
cap.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
webDriver = new RemoteWebDriver(new URL("http://"+serverIP+":4444/wd/hub"), cap);
webDriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
where serverIP is localhost if you want to run the application in your local system or if you want to run it in jenkins then you need the IP address of the selenium-hub server which can be found by running docker inspect on jenkins

Related

sonarqube scanner on circleci

I am using Sonarqube and CircleCI for code quality scan.
However, I don't know how if it is possible to start up a Sonarqube Server on CircleCI and use it to run the scanner.
This is my current config.yaml
version: 2.1
executors:
scanner:
docker:
- image: openjdk:11
commands:
check-code-quality:
description: Check Code Quality
parameters:
sonar_server_url:
type: string
description: "URL of your SonarQube server. e.g.: http://my.sonarqube,server:9000"
default: "$SONAR_SERVER"
sonar_login:
description: "Authentication key (sonar.login paramter) to access SonarQube and perform analysis"
type: string
default: "$SONAR_TOKEN"
sonar_sources:
description: "Where the files are located?"
type: string
default: "$SONAR_SOURCES"
steps:
- run:
name: Install Sonarqube scanner
command: |
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873.zip
unzip sonar-scanner-cli-4.2.0.1873.zip
- run:
name: Run Sonarscanner
command: |
export SONAR_SCANNER_OPTS="-Xmx2048m"
eval ./sonar-scanner-4.2.0.1873/bin/sonar-scanner \
-Dsonar.projectKey=projectKey
-Dsonar.host.url=<< parameters.sonar_server_url >> \
-Dsonar.sources=<< parameters.sonar_sources >> \
-Dsonar.login=<< parameters.sonar_login >>
jobs:
check-code-job:
executor: scanner
steps:
- check-code-quality
workflows:
check-code-quality-flow:
jobs:
- check-code-job:
context: lineclass
There is an error log when the job being executed:
...
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)
at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
... 7 more
Caused by: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9000
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.R...
This indicates that the Sonarqube Server is missing.
If you have experience running sonar-scanner on CircleCI please help.
Thank you.
After I change the image to sonarqube:8.9-community and fix the missing \ in the sonar-scanner command (at the end of -Dsonar.projectKey), it works.

Run time issues with Ballerina Integrator

I am trying to run the sample File Integration with FTP which is given by Ballerina Integrator.
While running the service i am facing same issue each and every time.
I have installed Ballerina Integrator only. I have done uninstall and installation freshly after that also Same issue.
Please help me.
I could successfully run the sample with following configurations. (sample data are given). Here I have used a Secured FTP server to do the configuration.
listener ftp:Listener dataFileListener = new({
protocol: ftp:SFTP,
host: "18.156.78.137",
port: 22,
secureSocket: {
basicAuth: {
username: "cloudloc",
password: "fsf#$#213"
}
},
path: "/clouddir/"
});
ftp:ClientEndpointConfig ftpConfig = {
protocol: ftp:SFTP,
host: "18.156.78.137",
port: 22,
secureSocket: {
basicAuth: {
username: "cloudloc",
password: "fsf#$#213"
}
}
};
Make sure you set the path parameter correctly in the dataFileListener. Without this parameter I could reproduce your attached error.
Once this is correctly configured you would get a log printed like follows.
2020-01-24 15:13:23,758 INFO [wso2/ftp] - Listening to remote server at 18.156.78.137...
2020-01-24 15:13:24,333 INFO [wso2/file_integration_using_ftp] - Added file path: /clouddir/a1.txt
2020-01-24 15:13:24,415 INFO [wso2/file_integration_using_ftp] - Added file: /clouddir/a1.txt - 12
Just install Ballerina Integrator alone which is packed with Ballerina 1.0.2 so no need to install Ballerina again or separately. From VSCode why output is not coming means,VSCode's market place all are upgraded with latest version.
Locally installed "BI with Ballerina" is lower version, In VSCode "BI with Ballerina" is latest one. Mismatched version is the main problem which i was faced.

Correct path for rabbitmq Docker container in Windows

I have a RabbitMQ Docker container in a docker-compose.yml file.
rabbit:
image: rabbitmq:3-management
ports:
- "15672:15672"
- "5672:5672"
- "61613:61613"
- "15674:15674"
volumes:
- ./enabled_plugins:/etc/rabbitmq/enabled_plugins
labels:
- "traefik.enable=true"
- "traefik.docker.network=default"
- "traefik.ws.port=15674"
- "traefik.ws.frontend.rule=PathPrefixStrip:/stomp/"
- "traefik.web.port=15672"
- "traefik.web.frontend.rule=PathPrefixStrip:/rabbit/"
The problem is that when I do docker-compose up -d, there is an error.
$ docker-compose up -d
Removing deploji-server_rabbit_1
deploji-server_postgres_1 is up-to-date
Starting 820ca92c591a_deploji-server_server_1 ...
Recreating 563cd247aa16_deploji-server_rabbit_1 ...
deploji-server_traefik_1 is up-to-date
Recreating 563cd247aa16_deploji-server_rabbit_1 ... error
Starting 98268bf1b8a7_deploji-server_worker_1 ... done
ERROR: for 563cd247aa16_deploji-server_rabbit_1 Cannot start service rabbit: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/c/Projects/deploji-server/enabled_plugins\\\" to rootfs \\\"/mnt/sda1/var/lib/docker/overlay2/bfcfb23713669e206d402b6c3a183d772750b527f35e5d0372d4f6982ddeb56aStarting 820ca92c591a_deploji-server_server_1 ... done
tmq/enabled_plugins\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for rabbit Cannot start service rabbit: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/c/Projects/deploji-server/enabled_plugins\\\" to rootfs \\\"/mnt/sda1/var/lib/docker/overlay2/bfcfb23713669e206d402b6c3a183d772750b527f35e5d0372d4f6982ddeb56a/merged\\\" at \\\"/mnt/sda1/var/lib/docker/overlay2/bfcfb23713669e206d402b6c3a183d772750b527f35e5d0372d4f6982ddeb56a/merged/etc/rabbitmq/enabled_plugins\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Encountered errors while bringing up the project.
There seems to be no problems in Linux environment, only on Windows. I assume the path for enabled_plugins file is incorrect. I've tried changing the mapping to something like
./enabled_plugins:/c/rabbitmq
and the container seems to start, but the server is not responding, so I guess the plugins from the enabled_plugins file were not properly installed.
Whole docker-compose.yml file can be seen here: https://github.com/maxmeister/deploji-server/blob/master/docker-compose.yml
Any advice on how could I make it run okay on my Windows machine? Thanks in advance.
I would suggest following the docs:
There are several options if use short syntax:
SHORT SYNTAX Optionally specify a path on the host machine
(HOST:CONTAINER), or an access mode (HOST:CONTAINER:ro).
You can mount a relative path on the host, that expands relative to
the directory of the Compose configuration file being used. Relative
paths should always begin with . or ...
volumes:
# Just specify a path and let the Engine create a volume
- /var/lib/mysql
# Specify an absolute path mapping
- /opt/data:/var/lib/mysql
# Path on the host, relative to the Compose file
- ./cache:/tmp/cache
# User-relative path
- ~/configs:/etc/configs/:ro
# Named volume
- datavolume:/var/lib/mysql
Related question and answers

Phantomjs headless on linux: WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP

I am experiencing issue with Phantomjs headless automation testing on linux. We are using Jenkins as our CI server. However, we are getting the error below:
phantomjs://platform/console++.js:263 in error
[ERROR - 2016-12-09T19:45:12.372Z] WebElementLocator -
_handleLocateCommand - Element(s) NOT Found: GAVE UP.
Search Stop Time: 1481312712354
phantomjs://platform/console++.js:263 in error
How we start phantomjs:
phantomjs --webdriver=8001
Environment:
Phantomjs: 2.1.1
Jenkins: 1.598
Linux: Linux xxx1247 2.6.32-573.12.1.el6.x86_64
Ruby: 1.9.3
Cucumber: 2.1.4
Selenium-webdriver: 2.53
Please share your solution. Thanks!
There can be a few causes for this. One of them can be that the get action to the Web URL failed. That means you are operating on an empty result, which will throw that error.
Since the webpage is not fetched, the element will not be there.

Gradle Docker plugin broken pipe on osx

Hi I try to use this awesome Gradle plugin: https://github.com/bmuschko/gradle-docker-plugin
I use the following URL obtained from my docker-machine / kitematic installation on osx:
docker-machine url default
tcp://192.168.99.100:2376
However using:
url = "tcp://192.168.99.100:2376"
results in the error:
org.apache.http.conn.UnsupportedSchemeException: tcp protocol is not supported
When I change the tcp to httpI get a different error:
INFO org.apache.http.impl.execchain.RetryExec - I/O exception (java.net.SocketException) caught when processing request: Broken pipe
[pool-4-thread-1] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
org.apache.http.client.ClientProtocolException
in case the gradle dockerBuildImage task is run.
But manually building the Dockerfile created by gradle works without any problems.
The following code can be used to replicate the problem. https://github.com/geoHeil/lab04/blob/master/build.gradle
Docker-machine enables TLS by default. I Switching to the TLSmode should be a good solution:
url = 'https://192.168.59.103:2376'
certPath = new File(System.properties['user.home'], '.boot2docker/certs/boot2docker-vm')

Resources