I have a bunch of UI tests written in Python using Selenium that open Chrome to run. I have a procedure to set up the driver. It works great. We now have a need to have the option to run the tests in IE. I used the same procedure and added ie references instead of chrome. IE works great now. BUT, Chrome STOPPED working. I have no idea why. I confirmed that the chrome alone works and immediately breaks after adding IE. I put the two functions below.
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.ie.options import Options
def openchrome(userid):
window_size = '1920,1080'
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--window-size=%s' % window_size)
chrome_options.add_argument('--no-sandbox')
driver = webdriver.Chrome(
input_path + 'chromedriver.exe', options=chrome_options)
url = settingsfile('url').strip()
statusmessage(url)
driver.get(url)
driver.maximize_window()
driver.implicitly_wait(3)
return driver
def openie(userid):
window_size = '1920,1080'
ie_options = Options()
ie_options.add_argument('--headless')
ie_options.add_argument('--window-size=%s' % window_size)
ie_options.add_argument('--no-sandbox')
driver = webdriver.Ie(input_path + 'IEDriverServer.exe', options=ie_options)
url = settingsfile('url').strip()
statusmessage(url)
driver.get(url)
driver.maximize_window()
driver.implicitly_wait(3)
return driver
Error:
Traceback (most recent call last):
File "C:/Users/username/Documents/QA Automation/record/Addrecord.py", line 15, in <module>
driver = openchrome(userid)
File "C:\Users\username\Documents\QA Automation\Utilities\Utilities.py", line 58, in openchrome
driver = webdriver.Chrome(
File "C:\Users\username\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
RemoteWebDriver.__init__(
File "C:\Users\username\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\username\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\username\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\username\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: No matching capabilities found
You imported the Options module with the same name for both drivers, for the chrome driver for both IE. Just use the term 'as' in any of the imports that should work correctly.
translated by google translator
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.ie.options import Options as IEOptions