Robot framework test on edge

hello,

im using docker image on gitlab runner with ubuntu 20.04 and edge driver 115.0.1901.183

robotframework==4.1.3
robotframework-seleniumlibrary==5.1.3

But im getting " Evaluating expression ‘sys.modules[‘selenium.webdriver’].EdgeOptions()’ failed: AttributeError: module ‘selenium.webdriver’ has no attribute ‘EdgeOptions’" when i try to open the browser

this is my code :

${options}=    Evaluate    sys.modules['selenium.webdriver'].EdgeOptions()    sys, selenium.webdriver
Call Method        ${options}    add_argument    --headless
Open Browser          about:blank         edge      options=${options}

The same configuration and code works on windows local machine

I would first check to make sure the versions of selenium on the docker machine is the same as on your local or the expected version.

You can also use the options string format, as in

Open Browser  about:blank  edge  options=add_argument("--headless=new")

noting also that the option for headless though Chromium-based browsers, like Edge, has been upgrade for just --headless to --headless=new [Reference].

You might be able to show the version within the script itself with something like

Evaluate     print(selenium.__version__)    selenium

or maybe

Evaluate     return selenium.__version__    selenium

Thank you
${options}= Evaluate sys.modules[‘selenium.webdriver’].EdgeOptions() sys, selenium.webdriver
tried Open Browser about:blank edge options=add_argument(“–headless=new”)

Evaluating expression ‘sys.modules[‘selenium.webdriver’].EdgeOptions()’ failed: AttributeError: module ‘selenium.webdriver’ has no attribute ‘EdgeOptions’

works on local but no luck on runner
im having the same version of selenium =4.2.0

That error is fairly straight forward. Unless you have something patching selenium, which is possible but doubtful, it would seem that the Python instance running on that docker machine, although the container may have 4.2.0 installed, has a 3.x or prior instance installed. EdgeOptions got introduced with Selenium v4.0.

Just tested out this script on my machine

*** Settings ***
Library    SeleniumLibrary

*** Test Cases ***
Get version of selenium used by the Python running this robot script
   Open Browser    about:blank    Chrome
   Evaluate     print(selenium.__version__)    selenium
   Evaluate     print(sys.exec_prefix)    sys

and it gives to me the version I see when running the same Python instance, in this case a virtualenv, that I am expecting. Might be worth trying this right before your line that is failing.
evaulate_python_version

[Edited: I add in the second Evaluate line which then prints out the “prefix” or directory of where the python which executed this script is. May be useful in debugging.]

[quote=“Ultra, post:8, topic:6366, full:true”]
hello

hello

i have 3.141.0 on docker image , but requirement file have 4.2.0
how can i resolve this issue

this is my installation on dockerfile:

Install necessary packages and dependencies

RUN echo ‘APT::Install-Recommends “false”;’ > /etc/apt/apt.conf
&& echo ‘APT::Install-Suggests “false”;’ >> /etc/apt/apt.conf
&& apt-get -qq update
&& apt-get install -yqq --no-install-recommends --no-install-suggests
lsb build-essential libssl-dev libffi-dev python3-dev python3-pip python-dev gcc phantomjs firefox
xvfb zip wget ca-certificates ntpdate gnupg openjdk-17-jdk unzip language-pack-fr
libnss3-dev libxss1 libappindicator3-1 libindicator7 gconf-service libgconf-2-4 libpango1.0-0 xdg-utils fonts-liberation

You are close to finding issue. It seems you just need to figure out or verify a few more configuration. Here are some questions that might help you …

Are you installing using the requirement file (I don’t see it there above)? What is the version for selenium given within the requirements file (is it pinned at 4.3.0 or something else)? And if you are installing with requirements are you sure that is the same Python that is executing the script? This last question is key. I suspect - although it might not be the case, only you can investigate - that the docker image has a Python already installed. So that means you need to check the versions and locations of which Python is executing. You might be able to add the following to the configuration script

which python

or maybe

which python3

Some other good informative or debugging scripts could include

robot --version
python --version

amongst others

in your " Install necessary packages and dependencies":

RUN echo ‘APT::Install-Recommends “false”;’ > /etc/apt/apt.conf
&& echo ‘APT::Install-Suggests “false”;’ >> /etc/apt/apt.conf
&& apt-get -qq update
&& apt-get install -yqq --no-install-recommends --no-install-suggests
lsb build-essential libssl-dev libffi-dev python3-dev python3-pip python-dev gcc phantomjs firefox
xvfb zip wget ca-certificates ntpdate gnupg openjdk-17-jdk unzip language-pack-fr
libnss3-dev libxss1 libappindicator3-1 libindicator7 gconf-service libgconf-2-4 libpango1.0-0 xdg-utils fonts-liberation

I can see that you install pip (python3-pip), but I don’t see anywhere where you use it to install your requirements

Since you mentioned a requirement file, I would have expected to see a line like:

pip install -r requirements.txt

If you have that and I just missed it, or if that still doesn’t work, you could try something like:

pip install -U -r requirements.txt

As -U tells pip to upgrade the modules if they are already installed

Hope that helps,

Dave.

Thank you for your support

Please check the following details:

Running: [/bin/bash -o pipefail -c python3 --version]
Python 3.8.10

Running: [/bin/bash -o pipefail -c python3 -m robot --version]
Robot Framework 4.1.3 (Python 3.8.10 on linux)

Running this Evaluate print(selenium.version), selenium from script gives: 3.141.0

My requirement file contains :
robotframework==4.1.3
selenium==4.2.0

Call used is : RUN pip3 install -U -r requirements.txt

i m still cant figure out the problem of getting this old version for selenium
i have tried to remove and install the new version but still no luck to update selenium

Can you show the log from the pip3 command? The clue as to what is happening should be in that log.

Dave.

Note: It’s best to wrap the log text with three back tick (```) on the line before and after your log to make it easier to read

Successfully installed Pillow-7.1.0 PyNaCl-1.3.0 PyYAML-5.1 WebOb-1.8.7 attrs-23.1.0 bcrypt-4.0.1 beautifulsoup4-4.12.2 certifi-2019.3.9 cffi-1.12.3 
chardet-3.0.4 cryptography-3.2 enum34-1.1.6 et-xmlfile-1.0.1 
exceptiongroup-1.1.3 future-0.16.0 h11-0.14.0 idna-2.8 ipaddress-1.0.22 
jdcal-1.4.1 jsonpatch-1.33 jsonpointer-2.4 natsort-6.0.0 ndg-httpsclient-0.5.1 openpyxl-2.6.2 outcome-1.3.0 paramiko-3.3.1 pyOpenSSL-19.0.0 pyasn1-0.4.5 pycparser-2.21
 robotframework-4.1.3 robotframework-angularjs-0.0.9
 robotframework-httplibrary-0.4.2 robotframework-pythonlibcore-4.2.0
 robotframework-seleniumlibrary-5.1.3 robotframework-sshlibrary-3.3.0 robotframework-xvfb-1.2.2 scp-0.14.5 selenium-4.2.0 six-1.16.0 sniffio-1.3.0 sortedcontainers-2.4.0 soupsieve-2.5 trio-0.22.2 trio-websocket-0.11.1 urllib3-1.26.12 waitress-2.1.2 webtest-3.0.0 wsproto-1.2.0 xvfbwrapper-0.2.9

COPY requirements.txt .
RUN pip3 install -U -r requirements.txt

My issue is still not yet resolved
Please advice or

According to your log, pip3 successfully installed robotframework-seleniumlibrary-5.1.3 and selenium-4.2.0, so I’m not sure why you’re still seeing selenium 4.13.0?

Are you using a python virtual environment?

Another thing you could check is the path, try adding this line to your robot file:

    Log    %{PATH}

Perhaps you have 2 python versions installed? and the pip3 command is installing the modules and libraries in one python version and robot is running from another?

Dave.

I have this
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin/geckodriver
As output of Log %{path}

this is my code

Install necessary packages and dependencies

RUN echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf \
    && echo 'APT::Install-Suggests "false";' >> /etc/apt/apt.conf \
    && apt-get -qq update \
    && apt-get install -yqq --no-install-recommends --no-install-suggests \
        lsb build-essential libssl-dev libffi-dev python3-dev python3-pip gcc phantomjs firefox \
        xvfb zip wget ca-certificates ntpdate gnupg openjdk-17-jdk unzip language-pack-fr \
        libnss3-dev libxss1 libappindicator3-1 libindicator7 gconf-service libgconf-2-4 libpango1.0-0 xdg-utils fonts-liberation

Do you have any suggestion

Thank you