Skip to content

Commit

Permalink
Made changes to add support for Edge in place of IE (Cherry picked co…
Browse files Browse the repository at this point in the history
…mmits and fixed conflicts)
  • Loading branch information
nelabhotlaR authored and rohandudam committed Oct 21, 2024
1 parent 07022e5 commit 2ac1fef
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
2 changes: 2 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ c) If your are using firefox 47 and above, you need to set up Geckodriver. Refer

d) On Ubuntu, you may run into an issue installing the cryptography module. You need to `sudo apt-get install libssl-dev` and then run `sudo pip install -r requirements.txt`

e) The Edge in Windows can not be downloaded automatically to the local cache (~/.cache/selenium) by Selenium Manager as it requires administrative access. When Edge is attempted to installed with Selenium Manager it will through ``edge can only be installed in Windows with administrator permissions.``

-----------
Continuous Integration and Support
-----------
Expand Down
4 changes: 3 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def test_obj(base_url, browser, browser_version, os_version, os_name, remote_fla
elif os.getenv('REMOTE_BROWSER_PLATFORM') == 'BS' and remote_flag.lower() == 'y':
test_obj.execute_javascript("""browserstack_executor: {"action": "setSessionStatus",
"arguments": {"status":"failed", "reason": "Exception occured"}}""")
if browser == "edge":
print(f"Selenium Manager requires administrator permissions to install Microsoft {browser} in Windows automatically ")

@pytest.fixture
def test_mobile_obj(mobile_os_name, mobile_os_version, device_name, app_package, app_activity, # pylint: disable=redefined-outer-name too-many-arguments too-many-locals
Expand Down Expand Up @@ -684,7 +686,7 @@ def pytest_addoption(parser):
dest="browser",
action="append",
default=[],
help="Browser. Valid options are firefox, ie and chrome")
help="Browser. Valid options are firefox, Edge and chrome")
parser.addoption("--app_url",
dest="url",
default=base_url_conf.ui_base_url,
Expand Down
4 changes: 2 additions & 2 deletions core_helpers/drivers/driverfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def get_local_driver(self, browser, browser_version):
browser_version = None
if browser.lower() == "ff" or browser.lower() == 'firefox':
local_driver = self.firefox_local(browser_version)
elif browser.lower() == "ie":
local_driver = self.explorer_local(browser_version)
elif browser.lower() == "edge":
local_driver = self.edge_local(browser_version)
elif browser.lower() == "chrome":
local_driver = self.chrome_local(browser_version)
elif browser.lower() == "opera":
Expand Down
8 changes: 4 additions & 4 deletions core_helpers/drivers/local_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def firefox_local(browser_version):
return local_driver

@staticmethod
def explorer_local(browser_version):
"""Get webdriver for internet explorer."""
options = webdriver.IeOptions()
def edge_local(browser_version):
"""Get webdriver for Edge."""
options = webdriver.EdgeOptions()
options.browser_version = browser_version
local_driver = webdriver.Ie()
local_driver = webdriver.Edge(options=options)

return local_driver

Expand Down
11 changes: 5 additions & 6 deletions core_helpers/web_app_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
Page class that all page models can inherit from
There are useful wrappers for common Selenium operations
"""

import inspect
from selenium.webdriver.common.by import By
import os,inspect
from core_helpers.drivers.driverfactory import DriverFactory
from .selenium_action_objects import Selenium_Action_Objects
from .remote_objects import Remote_Objects
Expand Down Expand Up @@ -248,7 +247,7 @@ def switch_frame(self,name=None,index=None,wait_time=2):
def get_element_attribute_value(self,element,attribute_name):
"Return the elements attribute value if present"
attribute_value = None
if (hasattr(element,attribute_name)):
if hasattr(element,attribute_name):
attribute_value = element.get_attribute(attribute_name)

return attribute_value
Expand Down Expand Up @@ -278,14 +277,14 @@ def accessibility_inject_axe(self):
try:
return self.axe_util.inject()
except Exception as e:
self.write(str(e),'critical')
self.write(str(e),'critical')

def accessibility_run_axe(self):
"Run Axe into the Page"
try:
return self.axe_util.run()
except Exception as e:
self.write(str(e),'critical')
self.write(str(e),'critical')

def snapshot_assert_match(self, value, snapshot_name):
"Asserts the current value of the snapshot with the given snapshot_name"
Expand All @@ -294,7 +293,7 @@ def snapshot_assert_match(self, value, snapshot_name):
self.snapshot_util.assert_match(value, snapshot_name)
result_flag = True
except Exception as e:
self.write(str(e),'critical')
self.write(str(e),'critical')

return result_flag

Expand Down
12 changes: 6 additions & 6 deletions integrations/cross_browsers/remote_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Set the desired option for running the test on a remote platform.
"""
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from selenium.webdriver.ie.options import Options as IeOptions
from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.safari.options import Options as SafariOptions
from appium.options.android import UiAutomator2Options
Expand All @@ -20,9 +20,9 @@ def firefox(browser_version):
return options

@staticmethod
def explorer(browser_version):
"""Set web browser as Explorer."""
options = IeOptions()
def edge(browser_version):
"""Set web browser as Edge."""
options = EdgeOptions()
options.browser_version = browser_version

return options
Expand All @@ -47,8 +47,8 @@ def get_browser(self, browser, browser_version):
"""Select the browser."""
if browser.lower() == 'ff' or browser.lower() == 'firefox':
desired_capabilities = self.firefox(browser_version)
elif browser.lower() == 'ie':
desired_capabilities = self.explorer(browser_version)
elif browser.lower() == 'edge':
desired_capabilities = self.edge(browser_version)
elif browser.lower() == 'chrome':
desired_capabilities = self.chrome(browser_version)
elif browser.lower() == 'safari':
Expand Down

0 comments on commit 2ac1fef

Please sign in to comment.