Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
# Version 16

### [Current changes]
- **[Add]** Added selenium grid functionality. Usage:
```shell
cd .../Framework/Built_In_Automation/Web/Selenium
docker-compose -f docker-compose-v3.yml up
```
- **[Fix]** Compare data *ignore_list_order* bug fix
- **[Fix]** Zeuz_auto_teardown variable bug fix
- **[Fix]** Mobile browser update bug fix
- **[Fix]** zeuz_pid_finder bug fix for chrome

- **[Add]** Authenticator code generator action is added for windows
- **[Improve]** Function handle capability inside csv cells is implemented
- **[Fix]** Windows_pid issue solved for image searching
Expand Down
86 changes: 70 additions & 16 deletions Framework/Built_In_Automation/Web/Selenium/BuiltInFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,26 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
"Dependency not set for browser. Please set the Apply Filter value to YES."
)
return CommonUtil.Exception_Handler(sys.exc_info(), None, ErrorMessage)

if Shared_Resources.Test_Shared_Variables('run_time_params'): # Look for remote config in runtime params
run_time_params = Shared_Resources.Get_Shared_Variables('run_time_params')
remote_config = run_time_params.get("remote_config")
if(remote_config):
remote_host = remote_config.get('host')
remote_browser_version = remote_config.get('browser_version')
if(remote_host):
try:
if requests.get(remote_host).status_code != 200:
remote_host = None
except requests.exceptions.RequestException as e:
remote_host = None
if remote_host == None:
CommonUtil.ExecLog(
sModuleInfo, "Remote host: %s is not up. Running the browser locally " % remote_config.get('host'), 3
)
else:
remote_host = None
remote_browser_version = None
# try:
# selenium_driver.close()
# except:
Expand Down Expand Up @@ -430,6 +450,8 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
ConfigModule.add_config_value("Selenium_driver_paths", "chrome_path", chrome_path)
options = Options()

if remote_browser_version:
options.set_capability("browserVersion",remote_browser_version)
# capability
if capability:
for key, value in capability.items():
Expand Down Expand Up @@ -474,11 +496,18 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
"download.directory_upgrade": True
}
options.add_experimental_option('prefs', prefs)
selenium_driver = webdriver.Chrome(
executable_path=chrome_path,
chrome_options=options,
desired_capabilities=d
)
if remote_host:
selenium_driver = webdriver.Remote(
command_executor= remote_host + "wd/hub",
options=options,
desired_capabilities=d
)
else:
selenium_driver = webdriver.Chrome(
executable_path=chrome_path,
chrome_options=options,
desired_capabilities=d
)
selenium_driver.implicitly_wait(WebDriver_Wait)
if not window_size_X and not window_size_Y:
selenium_driver.set_window_size(default_x, default_y)
Expand All @@ -502,6 +531,10 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
from sys import platform as _platform
from selenium.webdriver.firefox.options import Options
options = Options()

if remote_browser_version:
options.set_capability("browserVersion",remote_browser_version)

if "headless" in browser:
options.headless = True
if _platform == "win32":
Expand Down Expand Up @@ -533,12 +566,20 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
apps = "application/pdf;text/plain;application/text;text/xml;application/xml;application/xlsx;application/csv;application/zip"
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", apps)
profile.accept_untrusted_certs = True
selenium_driver = webdriver.Firefox(
executable_path=firefox_path,
capabilities=capabilities,
options=options,
firefox_profile=profile
)
if(remote_host):
selenium_driver = webdriver.Remote(
command_executor= remote_host + "wd/hub",
options=options,
desired_capabilities=capabilities,
browser_profile=profile
)
else:
selenium_driver = webdriver.Firefox(
executable_path=firefox_path,
capabilities=capabilities,
options=options,
firefox_profile=profile
)
selenium_driver.implicitly_wait(WebDriver_Wait)
if not window_size_X and not window_size_Y:
selenium_driver.set_window_size(default_x, default_y)
Expand All @@ -565,15 +606,28 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
"""
from Framework.edge_module.msedge.selenium_tools import EdgeOptions, Edge
download_dir = ConfigModule.get_config_value("sectionOne", "initial_download_folder", temp_config)
options = EdgeOptions()
capabilities = EdgeOptions().capabilities
options = webdriver.EdgeOptions()

if remote_browser_version:
options.set_capability("browserVersion",remote_browser_version)
capabilities = webdriver.EdgeOptions().capabilities
capabilities['acceptSslCerts'] = True
options.use_chromium = True
options.headless = "headless" in browser
options.add_experimental_option("prefs", {"download.default_directory": download_dir})
options.add_argument('--zeuz_pid_finder')
selenium_driver = Edge(executable_path=edge_path, options=options, capabilities=capabilities)

if(remote_host):
selenium_driver = webdriver.Remote(
command_executor= remote_host + "wd/hub",
options=options,
desired_capabilities=capabilities
)
else:
selenium_driver = Edge(
executable_path=edge_path,
options=options,
capabilities=capabilities
)
selenium_driver.implicitly_wait(WebDriver_Wait)
if not window_size_X and not window_size_Y:
selenium_driver.set_window_size(default_x, default_y)
Expand Down Expand Up @@ -803,7 +857,7 @@ def Go_To_Link(step_data, page_title=False):
else:
# any other shared capabilities can be added from the selenium document
capabilities[left.strip()] = right.strip()

# Todo: profile, argument, extension, chrome option => go_to_link
elif mid.strip().lower() in ("chrome option", "chrome options") and dependency["Browser"].lower() == "chrome":
browser_options.append([left, right.strip()])
Expand Down
80 changes: 80 additions & 0 deletions Framework/Built_In_Automation/Web/Selenium/docker-compose-v3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# To execute this docker-compose yml file use `docker-compose -f docker-compose-v3.yml up`
# Add the `-d` flag at the end for detached execution
# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3-video.yml down`
version: "3"
services:
chrome:
image: selenium/node-chrome:4.3.0-20220628
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
chrome_2:
image: selenium/node-chrome:102.0-20220609
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
edge:
image: selenium/node-edge:4.3.0-20220628
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443

firefox:
image: selenium/node-firefox:4.3.0-20220628
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443

chrome_video:
image: selenium/video:ffmpeg-4.3.1-20220628
volumes:
- ./videos:/videos
depends_on:
- chrome
environment:
- DISPLAY_CONTAINER_NAME=chrome
- FILE_NAME=chrome_video.mp4

edge_video:
image: selenium/video:ffmpeg-4.3.1-20220628
volumes:
- ./videos:/videos
depends_on:
- edge
environment:
- DISPLAY_CONTAINER_NAME=edge
- FILE_NAME=edge_video.mp4

firefox_video:
image: selenium/video:ffmpeg-4.3.1-20220628
volumes:
- ./videos:/videos
depends_on:
- firefox
environment:
- DISPLAY_CONTAINER_NAME=firefox
- FILE_NAME=firefox_video.mp4

selenium-hub:
image: selenium/hub:4.3.0-20220628
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"