I am using Selenoid with GitLab and it's working like a charm for Chrome, Edge and Firefox browsers.
However when it comes to Safari, the scripts are not able to connect to the Safari browser, getting errors like session not found and other similar errors.
Below are the different snippets used for Safari with Selenoid:
- gitlab-ci.yml
test:
stage: test
image: docker:latest
before_script:
- apt-get update && apt-get install -y maven
- apk add --update --no-cache curl && rm -rf /var/cache/apk/*
- docker pull maven:3.8-openjdk-11
- ls $CI_PROJECT_DIR
- >
docker run --rm
-v /builds:/builds
-v /var/run/docker.sock:/var/run/docker.sock
-v ${HOME}:/root
-e OVERRIDE_HOME=${HOME}
aerokube/cm:latest-release
selenoid start
--browsers-json /builds/myprojectpath/browsers.json
--args "-limit 1"
script:
- docker ps -a
- docker images -a
- curl docker:4444/status
- curl http://docker:4444/status
- curl -XPOST http://docker:4444/wd/hub/session -d '{"desiredCapabilities":{"browserName":"safari"}}'
- docker ps -a
- >
docker run --rm --network host -v "$(pwd)":/app -w /app maven:3.8-openjdk-11 mvn ${MAVEN_OPTS} test -Dcucumber.filter.tags=${FEATURE_TAG} -Dbrowser=safari
- browsers.json
{
"safari": {
"default": "15.0",
"versions": {
"15.0": {
"image": "browsers/safari:15.0",
"port": "4444",
"path": "/"
}
}
}
}
- Driver Initialisation Java Code
RemoteWebDriver driver;
SafariOptions options = new SafariOptions();
try {
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(120));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
Please find below error logs for:
- Selenoid
$ docker run --rm -v /builds:/builds -v /var/run/docker.sock:/var/run/docker.sock -v ${HOME}:/root -e OVERRIDE_HOME=${HOME} aerokube/cm:latest-release selenoid start --browsers-json /builds/myprojectpath/browsers.json --args "-limit 1"
Unable to find image 'aerokube/cm:latest-release' locally
latest-release: Pulling from aerokube/cm
Status: Downloaded newer image for aerokube/cm:latest-release
> Using Docker
- Your Docker API version is 1.41
> Downloading Selenoid...
- Fetching tags for image aerokube/selenoid
registry.ping url=https://index.docker.io/v2/
registry.tags url=https://index.docker.io/v2/aerokube/selenoid/tags/list repository=aerokube/selenoid
- Pulling image aerokube/selenoid:1.10.11
> Configuring Selenoid...
> Requested to sync configuration from "/builds/myprojectpath/browsers.json"...
- Pulling image browsers/safari:15.0
> Pulling video recorder image...
- Pulling image selenoid/video-recorder:latest-release
> Configuration saved to /root/.aerokube/selenoid/browsers.json
> Starting Selenoid...
> Successfully started Selenoid
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
abcd4a4bc123 aerokube/selenoid:1.10.11 "/usr/bin/selenoid -…" 2 seconds ago Up Less than a second 0.0.0.0:4444->4444/tcp selenoid
$ docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
aerokube/selenoid 1.10.11 ab1a2bcd3456 4 days ago 17.5MB
aerokube/cm latest-release 123a01b23456 6 weeks ago 17.9MB
maven 3.8-openjdk-11 1a2bc3defg45 8 months ago 664MB
browsers/safari 15.0 a1b234567890 17 months ago 932MB
selenoid/video-recorder latest-release 654z321456y7 2 years ago 37.6MB
$ curl docker:4444/status
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
{"total":1,"used":0,"queued":0,"pending":0,"browsers":{"safari":{"15.0":{}}}}
100 78 100 78 0 0 27358 0 --:--:-- --:--:-- --:--:-- 39000
$ curl http://docker:4444/status
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0{"total":1,"used":0,"queued":0,"pending":0,"browsers":{"safari":{"15.0":{}}}}
100 78 100 78 0 0 28581 0 --:--:-- --:--:-- --:--:-- 39000
$ curl -XPOST http://docker:4444/wd/hub/session -d '{"desiredCapabilities":{"browserName":"safari"}}'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 48 0 0 100 48 0 39 0:00:01 0:00:01 --:--:-- 39
100 115 100 67 100 48 39 28 0:00:01 0:00:01 --:--:-- 68
{"value":{"error":"invalid argument","message":"","stacktrace":""}}
- Driver initialization attempt via code
org.openqa.selenium.NoSuchSessionException: session deleted because of page crash or hang.
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '4.14.311-233.529.amzn2.x86_64', java.version: '11.0.16'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
I have tried with multiple combinations but it haven't worked:
- Adding tmpfs key-value in browsers.json
- Using acceptInsecureCerts with value true for SafariOptions
- Removing path key-value in browsers.json
It would be a great help if someone can help me with this issue.
shmSizevalue inbrowsers.json. aerokube.com/selenoid/latest/#_other_optional_fields