astebenkova 027bcefbd4 [chromedriver] Fix package installation
This commit alllows us to switch to JSON endpoints for chromedriver
since upstream changed the way of installation for version 115 or newer:
https://chromedriver.chromium.org/downloads#h.p_ID_32
https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints

Change-Id: I4a432ec36fe9e3f794cc6b7788bbdc04db3c8cf6
2023-07-20 13:35:46 +03:00

70 lines
2.3 KiB
YAML

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: Create selenium configuration directory
file:
path: /etc/selenium
state: directory
- name: Install selenium dependencies
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
apt:
name: "{{ packages }}"
vars:
packages:
- unzip
- wget
- xvfb
- jq
- name: Install selenium
pip:
name: selenium
state: latest
executable: pip3
- name: Add google chrome signing key
get_url:
url: https://dl-ssl.google.com/linux/linux_signing_key.pub
dest: /etc/apt/trusted.gpg.d/google-chrome.asc
- name: Add google chrome repository
apt_repository:
repo: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/google-chrome.asc] http://dl.google.com/linux/chrome/deb/ stable main"
filename: google-chrome
state: present
- name: Install google chrome
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
apt:
name: google-chrome-stable
update_cache: yes
install_recommends: false
# We need to install ChromeDriver compatible with Google Chrome version
- name: Get selenium chromedriver archive
shell: |-
set -ex
CHROME_VERSION=$(dpkg -s google-chrome-stable | grep -Po '(?<=^Version: ).*' | awk -F'.' '{print $1"."$2"."$3}')
DRIVER_URL=$(wget -qO- https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r --arg chrome_version "$CHROME_VERSION" '.channels.Stable.downloads.chrome[] | select(.platform=="linux64" and (.url | test($chrome_version))).url')
wget -O /tmp/chromedriver.zip ${DRIVER_URL}
args:
executable: /bin/bash
- name: Unarchive selenium chromedriver
unarchive:
src: /tmp/chromedriver.zip
dest: /etc/selenium
remote_src: yes
...