@@ -380,6 +380,26 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
380380 "Dependency not set for browser. Please set the Apply Filter value to YES."
381381 )
382382 return CommonUtil .Exception_Handler (sys .exc_info (), None , ErrorMessage )
383+
384+ if Shared_Resources .Test_Shared_Variables ('run_time_params' ): # Look for remote config in runtime params
385+ run_time_params = Shared_Resources .Get_Shared_Variables ('run_time_params' )
386+ remote_config = run_time_params .get ("remote_config" )
387+ if (remote_config ):
388+ remote_host = remote_config .get ('host' )
389+ remote_browser_version = remote_config .get ('browser_version' )
390+ if (remote_host ):
391+ try :
392+ if requests .get (remote_host ).status_code != 200 :
393+ remote_host = None
394+ except requests .exceptions .RequestException as e :
395+ remote_host = None
396+ if remote_host == None :
397+ CommonUtil .ExecLog (
398+ sModuleInfo , "Remote host: %s is not up. Running the browser locally " % remote_config .get ('host' ), 3
399+ )
400+ else :
401+ remote_host = None
402+ remote_browser_version = None
383403 # try:
384404 # selenium_driver.close()
385405 # except:
@@ -430,6 +450,8 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
430450 ConfigModule .add_config_value ("Selenium_driver_paths" , "chrome_path" , chrome_path )
431451 options = Options ()
432452
453+ if remote_browser_version :
454+ options .set_capability ("browserVersion" ,remote_browser_version )
433455 # capability
434456 if capability :
435457 for key , value in capability .items ():
@@ -474,11 +496,18 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
474496 "download.directory_upgrade" : True
475497 }
476498 options .add_experimental_option ('prefs' , prefs )
477- selenium_driver = webdriver .Chrome (
478- executable_path = chrome_path ,
479- chrome_options = options ,
480- desired_capabilities = d
481- )
499+ if remote_host :
500+ selenium_driver = webdriver .Remote (
501+ command_executor = remote_host + "wd/hub" ,
502+ options = options ,
503+ desired_capabilities = d
504+ )
505+ else :
506+ selenium_driver = webdriver .Chrome (
507+ executable_path = chrome_path ,
508+ chrome_options = options ,
509+ desired_capabilities = d
510+ )
482511 selenium_driver .implicitly_wait (WebDriver_Wait )
483512 if not window_size_X and not window_size_Y :
484513 selenium_driver .set_window_size (default_x , default_y )
@@ -502,6 +531,10 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
502531 from sys import platform as _platform
503532 from selenium .webdriver .firefox .options import Options
504533 options = Options ()
534+
535+ if remote_browser_version :
536+ options .set_capability ("browserVersion" ,remote_browser_version )
537+
505538 if "headless" in browser :
506539 options .headless = True
507540 if _platform == "win32" :
@@ -533,12 +566,20 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
533566 apps = "application/pdf;text/plain;application/text;text/xml;application/xml;application/xlsx;application/csv;application/zip"
534567 profile .set_preference ("browser.helperApps.neverAsk.saveToDisk" , apps )
535568 profile .accept_untrusted_certs = True
536- selenium_driver = webdriver .Firefox (
537- executable_path = firefox_path ,
538- capabilities = capabilities ,
539- options = options ,
540- firefox_profile = profile
541- )
569+ if (remote_host ):
570+ selenium_driver = webdriver .Remote (
571+ command_executor = remote_host + "wd/hub" ,
572+ options = options ,
573+ desired_capabilities = capabilities ,
574+ browser_profile = profile
575+ )
576+ else :
577+ selenium_driver = webdriver .Firefox (
578+ executable_path = firefox_path ,
579+ capabilities = capabilities ,
580+ options = options ,
581+ firefox_profile = profile
582+ )
542583 selenium_driver .implicitly_wait (WebDriver_Wait )
543584 if not window_size_X and not window_size_Y :
544585 selenium_driver .set_window_size (default_x , default_y )
@@ -565,15 +606,28 @@ def Open_Browser(dependency, window_size_X=None, window_size_Y=None, capability=
565606 """
566607 from Framework .edge_module .msedge .selenium_tools import EdgeOptions , Edge
567608 download_dir = ConfigModule .get_config_value ("sectionOne" , "initial_download_folder" , temp_config )
568- options = EdgeOptions ()
569- capabilities = EdgeOptions ().capabilities
609+ options = webdriver .EdgeOptions ()
610+
611+ if remote_browser_version :
612+ options .set_capability ("browserVersion" ,remote_browser_version )
613+ capabilities = webdriver .EdgeOptions ().capabilities
570614 capabilities ['acceptSslCerts' ] = True
571615 options .use_chromium = True
572616 options .headless = "headless" in browser
573617 options .add_experimental_option ("prefs" , {"download.default_directory" : download_dir })
574618 options .add_argument ('--zeuz_pid_finder' )
575- selenium_driver = Edge (executable_path = edge_path , options = options , capabilities = capabilities )
576-
619+ if (remote_host ):
620+ selenium_driver = webdriver .Remote (
621+ command_executor = remote_host + "wd/hub" ,
622+ options = options ,
623+ desired_capabilities = capabilities
624+ )
625+ else :
626+ selenium_driver = Edge (
627+ executable_path = edge_path ,
628+ options = options ,
629+ capabilities = capabilities
630+ )
577631 selenium_driver .implicitly_wait (WebDriver_Wait )
578632 if not window_size_X and not window_size_Y :
579633 selenium_driver .set_window_size (default_x , default_y )
@@ -803,7 +857,7 @@ def Go_To_Link(step_data, page_title=False):
803857 else :
804858 # any other shared capabilities can be added from the selenium document
805859 capabilities [left .strip ()] = right .strip ()
806-
860+
807861 # Todo: profile, argument, extension, chrome option => go_to_link
808862 elif mid .strip ().lower () in ("chrome option" , "chrome options" ) and dependency ["Browser" ].lower () == "chrome" :
809863 browser_options .append ([left , right .strip ()])
0 commit comments