We are trying to setup an automation testing environment for a web application. This web application will be hosted on Ubuntu server. In QA environment, we are trying to perform automated testing.
Environment information is as below:
- Operating System: Ubuntu 20.04 and/or 21.04
- Programming Language used: Python3 (3.8.10)
- Automation Tool: Selenium
- Desired browser: MS Edge
Flexibility:
We can use different version of Python or Ubuntu for this to work, but since MS Edge is client's preferred browser that can't be replaced with Firefox or other available browser. Though we can use different version of edge, if it works. And we are able to test the same in chrome browser successfully.
We can use different Linux Distros as long as it is stable version.
What we have already tried?
Also tried to follow the same instruction as we did for chrome. For installing chrome driver we followed 'https://www.thenerdlife.com/blog/how-to-install-chromedriver-on-ubuntu/'. So we did the same for edge and replaced "chromedriver" with "msedgedriver" in the script.
We have installed MS Edge (DEV v93.0.933.1) on Ubuntu 20.04. As for webdriver, we found it on 'https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/' and copied the file to the same location as python test file.
We also tried to rename the "msedgedriver" to "MicrosoftWebDriver.exe" (the file that was placed with python program). Coming from windows background, this thing usually works.
Python program
from selenium import webdriver
driver = webdriver.Edge()
driver.get('https://www.google.com/')
> Traceback (most recent call last):
File "/home/devang/.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'MicrosoftWebDriver.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/devang/GitHub/AutomationSampleTest/ieEdgeBrowse.py", line 3, in <module>
driver = webdriver.Edge()
File "/home/devang/.local/lib/python3.8/site-packages/selenium/webdriver/edge/webdriver.py", line 56, in __init__
self.edge_service.start()
File "/home/devang/.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'MicrosoftWebDriver.exe' executable needs to be in PATH. Please download from http://go.microsoft.com/fwlink/?LinkId=619687
EDIT
Also tried following code to pass the driver file location:
from selenium import webdriver
from selenium.webdriver.edge.options import Options
options = webdriver.EdgeOptions()
options.use_chromium = True
options.binary_location = "/home/devang/GitHub/AutomationSampleTest/msedgedriver"
driver = webdriver.Edge(options = options)
driver.get('https://www.google.com/')
For above code it is throwing different error:
Traceback (most recent call last):
File "/home/devang/GitHub/AutomationSampleTest/ieEdgeBrowse.py", line 3, in <module>
options = webdriver.EdgeOptions()
AttributeError: module 'selenium.webdriver' has no attribute 'EdgeOptions'
Question:
Is it even possible to do automated testing for MS Edge in Ubuntu using Python3 and Selenium?
If yes then how? Please break it down to small easy steps to follow as I am a new Ubuntu user.