0

As a side project, I wrote a Python module that's basically a wrapper for Selenium. I've tested all the functionality with Chrome and Firefox only and I'm now trying to add Edge. I'm having a problem getting my tests to pass in my Travis CI (Linux) instance and I think it's because MS Edge and msedgedriver are the dev versions in the build server, 91.0.852.0 at the time of writing this.

This is my suspicion because the tests pass on my local machine, a Windows system using the latest non-dev version of Edge and its driver, 90.0.818.41. I'm using selenium 3.141.0 and msedge-selenium-tools 3.141.3.

I would try to use the non-dev versions in the build server if it were possible, but as far as I can tell, version 91 is the earliest Edge and msedgedriver compatible with Linux.

To get an idea of the kind of errors I'm getting, here's a sample test script:

from msedge.selenium_tools import EdgeOptions
from msedge.selenium_tools import webdriver as EdgeDriver

edge_options = EdgeOptions()
edge_options.use_chromium = True
driver = EdgeDriver.WebDriver(options=edge_options)

and the error I get from this is:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: No matching capabilities found

It's my understanding that this error happens when msedgedriver is not in the executable path. In Travis CI, I have the dev version of msedgedriver in the executable path though, which is another reason why I'm thinking the problem is because I'm using the dev releases.

Here's the relevant part of my .travis.yml file:

   # Get Edge and its driver
  - curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
  - sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
  - sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
  - sudo rm microsoft.gpg
  - sudo apt update
  - sudo apt install microsoft-edge-dev
  - wget https://msedgedriver.azureedge.net/91.0.852.0/edgedriver_linux64.zip -P ~/
  - unzip ~/edgedriver_linux64.zip -d ~/
  - rm ~/edgedriver_linux64.zip
  - sudo mv -f ~/msedgedriver /usr/local/share/
  - sudo chmod 777 /usr/local/share/msedgedriver
  - sudo ln -s /usr/local/share/msedgedriver /usr/local/bin/msedgedriver
    # Debugging statement, remove when this is figured out
  - which msedgedriver
  - echo $PATH
  - ls /usr/local/share
  - ls /usr/local/bin

I can tell from the stuff under # Debugging statement... that msedgedriver is in the executable path. Does anyone have any ideas on what is causing my problems or a way around them? If it helps, you can check out the relevant pull request in which I'm having these problems.

Thank you so much in advanced!

ewhiting
  • 222
  • 1
  • 8

1 Answers1

1

You can try the following code to see if it works well in Linux. Please note to change the paths in the code to your owns:

from msedge.selenium_tools import EdgeOptions, Edge

options = EdgeOptions()
options.use_chromium = True
options.binary_location = r"/usr/bin/microsoft-edge-dev"
options.set_capability("platform", "LINUX")

webdriver_path = r"/your_path/msedgewebdriver"

browser = Edge(options=options, executable_path=webdriver_path)
browser.get("https://www.google.com")

Reference link: Python Selenium Settings On Microsoft Edge Dev On Linux

Yu Zhou
  • 6,874
  • 1
  • 4
  • 20
  • the script works locally, thank you so so much! I'm off to go work it into my project. You saved me a lot of time, thanks a ton! – ewhiting Apr 21 '21 at 04:36