Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome Alpine (Chromium) #93

Closed
aleksandr-kotlyar opened this issue Feb 29, 2020 · 2 comments · Fixed by aleksandr-kotlyar/webdriver_manager#1
Closed

Chrome Alpine (Chromium) #93

aleksandr-kotlyar opened this issue Feb 29, 2020 · 2 comments · Fixed by aleksandr-kotlyar/webdriver_manager#1
Assignees

Comments

@aleksandr-kotlyar
Copy link
Collaborator

aleksandr-kotlyar commented Feb 29, 2020

Problem

If use current version webdriver_manager 2.3.0 with Apline linux distributions - it can't find chrome browser in path, because there is no google-chrome distib at alpine repository.

Here is the code:

import logging
from webdriver_manager import utils
def test_chrome_version():
    logging.info(utils.chrome_version())

Here is the stacktrace:

_____________________________ test_chrome_version ______________________________
src/test/test_wdm.py:16: in test_chrome_version
    logging.info(utils.chrome_version())
/usr/local/lib/python3.7/site-packages/webdriver_manager/utils.py:98: in chrome_version
    .format(cmd)
E   ValueError: Could not get version for Chrome with this command: google-chrome --version

Here is Dockerfile python:3.7-alpine + chrome:3.11-alpine

Solution

I think we need to add checker if linux uses chromium or google-chrome browser.
I suggest two vartiants:

First

That we can add check if OS.ID is Alpine, we can try to extract id of distribution like here, but python-like:

$ cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.3
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
$ source /etc/os-release && echo "$ID"
alpine

Second

Add second try to execute cmd='chromium --version' if os_name() == OSType.LINUX:

# webdriver_manager/utils.py
def chrome_version():
    pattern = r'\d+\.\d+\.\d+'
    cmd_mapping = {
        OSType.LINUX: 'google-chrome --version',
        OSType.MAC: r'/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version',
        OSType.WIN: r'reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version'
    }

    cmd = cmd_mapping[os_name()]
    stdout = os.popen(cmd).read()
    version = re.search(pattern, stdout)
    if not version:
        if os_name() == OSType.LINUX:
            cmd = 'chromium-browser --version'
            try:
                stdout = os.popen(cmd).read()
                version = re.search(pattern, stdout)
                assert version
                return version.group(0)
            except AssertionError:
                raise ValueError('Could not get version for Chrome with this command: {}'.format(cmd))
        raise ValueError('Could not get version for Chrome with this command: {}'.format(cmd))
    return version.group(0)

I can make a PR, but want to discuss first, which solution is better.
@SergeyPirogov what do you think, which solution is better? Or maybe we should wait if someone can suggest the best one?

@SergeyPirogov
Copy link
Owner

Just need to create chromium wd manager and use IT

@aleksandr-kotlyar
Copy link
Collaborator Author

@SergeyPirogov understood. Will try to create some of chromium wd manager in next few hours. If there will be no PR - then i stucked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants