pytest-dev / pytest-selenium

Plugin for running Selenium with pytest
Other
333 stars 120 forks source link

Error trying to run tests using Edge #284

Open mickyJNST opened 2 years ago

mickyJNST commented 2 years ago

Using v2.0.1, the following error is thrown when --capability browserName edge:

            elif browser == "EDGE":
>               key = edge_options.KEY
E               AttributeError: 'Options' object has no attribute 'KEY'

../python_venvs/default/lib/python3.9/site-packages/pytest_selenium/pytest_selenium.py:115: AttributeError

Here is a screenshot from debugger:

pytest_selenium_edge_error

BeyondEvil commented 2 years ago

Would you mind sharing a little more information regarding your environment? OS, python and pytest versions etc?

If possible, we would truly appreciate a minimal reproducible example. Thanks 🙏

mickyJNST commented 2 years ago

Sure thing @BeyondEvil - here you go:

os: macOS BigSur python: 3.9.6 pytest: 6.2.2

One thing I noticed after revisiting this topic to write this response is that I had the selenium-3.141 package installed. After uninstalling this, and also uninstalling and reinstalling pytest-selenium, I see that selenium-4.1.3 is installed...and, I no longer get the original error I reported. However, my tests still don't run using Edge. There is no error now - pytest just runs without actually doing anything (and never actually finishes).

Note, I am using the selenium/standalone-edge Docker image from https://github.com/SeleniumHQ/docker-selenium and running tests with the following pytest parameters:

--driver Remote --selenium-host localhost --selenium-port 4444 --capability browserName edge

The same setup using Chrome and Firefox works fine. Unless something obvious jumps out to you given this new information, I will work on putting together a minimal reproducible example.

BeyondEvil commented 2 years ago

Thanks for the extra info.

I've been away for a while, so I'm not in the loop wrt. Selenium 4, so unfortunately nothing obvious jumps out. :(

BeyondEvil commented 2 years ago

pytest-selenium v4 was just released. Can you check and see if this issue is still relevant? @mickyJNST

mickyJNST commented 2 years ago

Hey @BeyondEvil - I am still running into the same issue. I created this simple example that demonstrates the problem. I granted you access and the README hopefully has enough info to reproduce the issue. Let me know if you need more info.

BeyondEvil commented 2 years ago

Hey @BeyondEvil - I am still running into the same issue. I created this simple example that demonstrates the problem. I granted you access and the README hopefully has enough info to reproduce the issue. Let me know if you need more info.

Appreciate it! Will take look during my day. 👍

BeyondEvil commented 2 years ago

Things Are Never Easy ™️

I happen to run an M1 MacBook (Apple Silicon) and the regular docker images doesn't support that.

They have experimental support in something called Seleniarm (which I've actually used).

However, they don't have prebuilt images for Edge 😏

So it's going to take a little bit of extra work unfortunately.

BeyondEvil commented 2 years ago

Sorry, I've spent 2 hours trying to get mainly the seleniarm Edge image building and running properly on my machine now - without any luck.

Not sure what my next move is.

micky1uphealth commented 2 years ago

Ugh - that sucks. The one thought I had was to run Selenium "the old fashioned way" i.e. run Selenium \ Edge directly on machine, outside of Docker. If the original problem is reproducible using this setup then good - will allow for further debugging of the original issue. If not, then at least it narrows down the source of the issue. I can give this a shot some time today \ this weekend if I get a chance.

BeyondEvil commented 2 years ago

I have a Mac Mini at home, I can see if I can spin this up on that (it's an intel machine) during the weekend too.

Whoever gets to it first can report back @micky1uphealth

BeyondEvil commented 2 years ago

Sorry man, my mac mini is too old (2011) which means it's stuck on High Sierra, which means Docker doesn't support it any longer, which means I can't run docker-compose above Version: 2...

BeyondEvil commented 2 years ago

So, I managed to get the images running on one of my NAS' 😂

I took a step back and tested this with pure selenium (w/o the pytest-selenium plugin) and I had the same issue you described.

Anyway, after reading this: https://www.selenium.dev/documentation/webdriver/browsers/edge/

And adjusting accordingly, it's now working. 😊

I'm probably going to fix this and re-release 4.0.0.

BeyondEvil commented 2 years ago

Shit. This is gonna take some effort. It's going to require quite some effort to fix this properly.

I can't see an easy fix unfortunately.