Hi Team,
I am working on project which have to deal with new Microsoft chromium Edge Browser. I was not able to access the browser elements. Could any one help me unblocking this issue. Thanks in advance.
Hi Team,
I am working on project which have to deal with new Microsoft chromium Edge Browser. I was not able to access the browser elements. Could any one help me unblocking this issue. Thanks in advance.
Last time I looked one needed to do few things:
True
. Something like this should work:| Open Browser | url | edge | options=use_chromium=True |
I am trying to use the above mentioned steps. But I am facing an error saying, “Options object has no attribute use_chromium”
That usually indicates that Selenium 4 is not installed. Execute pip list
and verify the Selenium version. If 4.0 is not installed, do pip install -U --pre selenium
There is an alternate way for that in case you do not want to upgrade to Selenium4.
first Run msedgedriver.exe from the command line (i.e. msedgedriver.exe). It will start msedgedriver on port 9515 (you can choose port). Start the browser as given bellow.
| Open Browser | url | edge | remote_url=http://locahost:9515 |
Thanks
Vinay
I wrote a plugin that helps to use Edge Chromium with SeleniumLibrary & 3rd selenium, it uses [https://github.com/microsoft/edge-selenium-tools](http://Selenium Tools For Microsoft Edge) and no need to update the selenium to alpha version.
Think it could help you.
Tested versions:
Usage of plugin:
Library SeleniumLibrary plugins=plugins.EdgePlugin
Open Browser ${URL} Edge options=use_chromium=True;headless=True
Plugin:
import importlib
from selenium import webdriver
from SeleniumLibrary import BrowserManagementKeywords
from SeleniumLibrary.utils import is_truthy, is_falsy
from SeleniumLibrary.keywords.webdrivertools import WebDriverCreator, SeleniumOptions
from msedge.selenium_tools import Edge as EdgePluginDriver
class EdgePlugin(BrowserManagementKeywords):
'''
This plugin is used to adapt SeleniumLibrary to run Edge browser
(even chromium based version) with stable selenium version (3.141).
It uses special msedge-selenium-tools
that allows driving the new Microsoft Edge (Chromium) browser
and use the latest functionality with no need to update to the alpha 4th selenium version.
'''
def __init__(self, ctx):
BrowserManagementKeywords.__init__(self, ctx)
self._webdriver_creator = _EdgePluginWebDriverCreator(self.log_dir)
class _EdgePluginWebDriverCreator(WebDriverCreator):
def __init__(self, log_dir):
self.log_dir = log_dir
self.selenium_options = _EdgePluginSeleniumOptions()
def create_edge(self, desired_capabilities, remote_url, options=None, service_log_path=None,
executable_path='msedgedriver.exe'):
if is_truthy(remote_url):
defaul_caps = webdriver.DesiredCapabilities.EDGE.copy()
desired_capabilities = self._remote_capabilities_resolver(
desired_capabilities, defaul_caps)
return self._remote(desired_capabilities, remote_url)
if is_falsy(executable_path):
executable_path = self._get_executable_path(EdgePluginDriver)
return EdgePluginDriver(options=options,
service_log_path=service_log_path,
executable_path=executable_path,
**desired_capabilities)
class _EdgePluginSeleniumOptions(SeleniumOptions):
def _import_options(self, browser):
if browser == 'edge':
options = importlib.import_module('msedge.selenium_tools.options')
return options.Options
else:
return super(_EdgePluginSeleniumOptions, self)._import_options(browser)
@MrBIN89 Most appreciated, you saved us a lot of trouble
Hi MrBIN89,
I am relatively new to this, and I was wondering how to install your plugin to be able to use it with my robot scripts?
Do I need to include in a .py as a resource?
Thank you very much for the help!
Kind Regards,
Oliver
Hey @oli129,
I ended up taking that code and implementing it here:
https://github.com/Accruent/robotframework-zoomba/blob/master/src/Zoomba/Helpers/EdgePlugin.py
Some instructions on its use can be found at the bottom of this section here.
If you wanted to use it with base SeleniumLibrary you would need to copy that file somewhere your code could access and then do something like:
Library SeleniumLibrary plugins=Path.To.EdgePlugin
Open Browser https://www.google.com browser=Edge options=use_chromium=True
Hi @Wolfe1,
thank you very much for the quick input! I am looking into it now.
When trying to use the base Selenium library, with the following method Library SeleniumLibrary plugins=C:/SVN/edge_chromium.py it throws the following error:
Initializing test library ‘SeleniumLibrary’ with arguments [ plugins=C:/SVN/edge_chromium.py ] failed: Importing test library: ‘C:/SVN/edge_chromium.py’ failed.
So if that works you need to remove the ‘.py’ part at the end, and I would suggest naming the .py file to be the same as the class, ‘EdgePlugin’. Given I am not sure if thay path will work as it needs to be relative to the library import.
So with that said you would need to do something like:
Library | SeleniumLibrary | plugins=SVN.EdgePlugin
Otherwise if you want to use that library I linked it it extends SeleniumLibrary so you would be able to work simply by installing it and using:
Library | Zoomba.GUILibrary | plugins=Zoomba.Helpers.EdgePlugin
Hi @Wolfe1,
thank you very much for the ideas! Both of your solutions worked out great! I was able to execute my test following your description!
Again, I do appreciate your help!
This works for me, but I’m not sure how to automate legacy web applications within Edge Chromium IE Mode. Any ideas with that?
Is it possible to do something like:
Open Browser | url | edge | options=use_chromium=True; desired_capability=ie
Any ideas would be appreciated.
AFIAIK IE Mode just launches IE11 in Edge window
I guess what I’m asking is how do we get IE11 to open in Edge Chromium in this way so that I can launch and automate legacy sites? I don’t want to automate these in IE11 itself but in Edge Chromium in IE compatibility mode.
How do we do this within Robot Framework?
Even if some magical way you colud do that, chromedriver cannot control IE.
IE mode is IE browser in Edge tab, so to contol it you had to use IEdriver.
I understand what you mean, but that’s what I’m asking now. Using IEDriver, what are the options that we need to set and how do we write this in Robot Framework?
Even if it’s IEDriver that’s used, the ultimate aim is to launch and navigate through the site on a Edge Chromium.
Just take IEDriver and automate IE. Fact that it will be launched inside Edge window changes nothing.
Here is the issue:
When the web application is launched manually in Edge Chromium, it launches as expected. But, if the same site is launched via an automated Edge Chromium browser it doesn’t load. This doesn’t happen for other sites that aren’t reliant on IE compatibility mode.
It’s essential that a the automated test happens on Edge Chromium and not IE itself.
Well, maybe you can combine info in this thread with SO
Good luck )