How to use mock_file_detector method in SeleniumLibrary

Best Python code snippet using SeleniumLibrary

test_webdrivercreator.py

Source:test_webdrivercreator.py Github

copy

Full Screen

...96def test_chrome_remote_no_caps(creator):97 url = 'http://localhost:4444/wd/hub'98 expected_webdriver = mock()99 capabilities = webdriver.DesiredCapabilities.CHROME.copy()100 file_detector = mock_file_detector(creator)101 when(webdriver).Remote(command_executor=url,102 browser_profile=None,103 desired_capabilities=capabilities, options=None,104 file_detector=file_detector).thenReturn(expected_webdriver)105 driver = creator.create_chrome({}, url)106 assert driver == expected_webdriver107def test_chrome_remote_caps(creator):108 url = 'http://localhost:4444/wd/hub'109 expected_webdriver = mock()110 capabilities = {"browserName": "chrome"}111 file_detector = mock_file_detector(creator)112 when(webdriver).Remote(command_executor=url,113 browser_profile=None,114 desired_capabilities=capabilities, options=None,115 file_detector=file_detector).thenReturn(expected_webdriver)116 driver = creator.create_chrome({'desired_capabilities': capabilities}, url)117 assert driver == expected_webdriver118def test_chrome_remote_caps_no_browser_name(creator):119 url = 'http://localhost:4444/wd/hub'120 expected_webdriver = mock()121 capabilities = {'browserName': 'chrome', 'key': 'value'}122 file_detector = mock_file_detector(creator)123 when(webdriver).Remote(command_executor=url,124 browser_profile=None,125 desired_capabilities=capabilities, options=None,126 file_detector=file_detector).thenReturn(expected_webdriver)127 driver = creator.create_chrome({'desired_capabilities': {'key': 'value'}}, url)128 assert driver == expected_webdriver129def test_chrome_healdless(creator):130 expected_webdriver = mock()131 options = mock()132 when(webdriver).ChromeOptions().thenReturn(options)133 when(webdriver).Chrome(options=options, service_log_path=None).thenReturn(expected_webdriver)134 driver = creator.create_headless_chrome({}, None)135 assert options.headless == True136 assert driver == expected_webdriver137def test_chrome_healdless_with_grid(creator):138 expected_webdriver = mock()139 options = mock()140 when(webdriver).ChromeOptions().thenReturn(options)141 remote_url = 'localhost:4444'142 capabilities = webdriver.DesiredCapabilities.CHROME.copy()143 file_detector = mock_file_detector(creator)144 when(webdriver).Remote(command_executor=remote_url,145 options=options, browser_profile=None,146 desired_capabilities=capabilities,147 file_detector=file_detector).thenReturn(expected_webdriver)148 driver = creator.create_headless_chrome({}, remote_url)149 assert options.headless == True150 assert driver == expected_webdriver151def test_firefox(creator):152 expected_webdriver = mock()153 profile = mock()154 when(webdriver).FirefoxProfile().thenReturn(profile)155 log_file = get_geckodriver_log()156 when(webdriver).Firefox(options=None,157 firefox_profile=profile,158 service_log_path=log_file).thenReturn(expected_webdriver)159 driver = creator.create_firefox({}, None, None)160 assert driver == expected_webdriver161 verify(webdriver).FirefoxProfile()162def test_get_ff_profile_real_path(creator):163 profile_path = '/path/to/profile'164 profile_mock = mock()165 when(webdriver).FirefoxProfile(profile_path).thenReturn(profile_mock)166 profile = creator._get_ff_profile(profile_path)167 assert profile == profile_mock168def test_get_ff_profile_no_path(creator):169 profile_mock = mock()170 when(webdriver).FirefoxProfile().thenReturn(profile_mock)171 profile = creator._get_ff_profile(None)172 assert profile == profile_mock173def test_get_ff_profile_instance_FirefoxProfile(creator):174 input_profile = webdriver.FirefoxProfile()175 profile = creator._get_ff_profile(input_profile)176 assert profile == input_profile177def test_firefox_remote_no_caps(creator):178 url = 'http://localhost:4444/wd/hub'179 profile = mock()180 when(webdriver).FirefoxProfile().thenReturn(profile)181 expected_webdriver = mock()182 capabilities = webdriver.DesiredCapabilities.FIREFOX.copy()183 file_detector = mock_file_detector(creator)184 when(webdriver).Remote(command_executor=url,185 browser_profile=profile, options=None,186 desired_capabilities=capabilities,187 file_detector=file_detector).thenReturn(expected_webdriver)188 driver = creator.create_firefox({}, url, None)189 assert driver == expected_webdriver190def test_firefox_remote_caps(creator):191 url = 'http://localhost:4444/wd/hub'192 profile = mock()193 when(webdriver).FirefoxProfile().thenReturn(profile)194 expected_webdriver = mock()195 capabilities = {"browserName": "firefox"}196 file_detector = mock_file_detector(creator)197 when(webdriver).Remote(command_executor=url,198 browser_profile=profile, options=None,199 desired_capabilities=capabilities,200 file_detector=file_detector).thenReturn(expected_webdriver)201 driver = creator.create_firefox({'desired_capabilities': capabilities}, url, None)202 assert driver == expected_webdriver203def test_firefox_remote_caps_no_browsername(creator):204 url = 'http://localhost:4444/wd/hub'205 profile = mock()206 when(webdriver).FirefoxProfile().thenReturn(profile)207 expected_webdriver = mock()208 capabilities = {'browserName': 'firefox', 'version': '66.02'}209 file_detector = mock_file_detector(creator)210 when(webdriver).Remote(command_executor=url,211 browser_profile=profile, options=None,212 desired_capabilities=capabilities,213 file_detector=file_detector).thenReturn(expected_webdriver)214 driver = creator.create_firefox({'capabilities': {"version": "66.02"}}, url, None)215 assert driver == expected_webdriver216def test_firefox_profile(creator):217 expected_webdriver = mock()218 profile = mock()219 profile_dir = '/profile/dir'220 when(webdriver).FirefoxProfile(profile_dir).thenReturn(profile)221 log_file = get_geckodriver_log()222 when(webdriver).Firefox(options=None, service_log_path=log_file,223 firefox_profile=profile).thenReturn(expected_webdriver)224 driver = creator.create_firefox({}, None, profile_dir)225 assert driver == expected_webdriver226def test_firefox_headless(creator):227 expected_webdriver = mock()228 profile = mock()229 when(webdriver).FirefoxProfile().thenReturn(profile)230 options = mock()231 when(webdriver).FirefoxOptions().thenReturn(options)232 log_file = get_geckodriver_log()233 when(webdriver).Firefox(options=options, service_log_path=log_file,234 firefox_profile=profile).thenReturn(expected_webdriver)235 driver = creator.create_headless_firefox({}, None, None)236 assert driver == expected_webdriver237def test_firefox_headless_with_grid_caps(creator):238 expected_webdriver = mock()239 options = mock()240 when(webdriver).FirefoxOptions().thenReturn(options)241 profile = mock()242 when(webdriver).FirefoxProfile().thenReturn(profile)243 remote_url = 'localhost:4444'244 capabilities = {'browserName': 'firefox', 'key': 'value'}245 file_detector = mock_file_detector(creator)246 when(webdriver).Remote(command_executor=remote_url, options=options,247 desired_capabilities=capabilities,248 browser_profile=profile,249 file_detector=file_detector).thenReturn(expected_webdriver)250 driver = creator.create_headless_firefox({'capabilities': {'key': 'value'}}, remote_url, None)251 assert driver == expected_webdriver252 assert options.headless == True253def test_firefox_headless_with_grid_no_caps(creator):254 expected_webdriver = mock()255 options = mock()256 when(webdriver).FirefoxOptions().thenReturn(options)257 profile = mock()258 when(webdriver).FirefoxProfile().thenReturn(profile)259 remote_url = 'localhost:4444'260 capabilities = webdriver.DesiredCapabilities.FIREFOX.copy()261 file_detector = mock_file_detector(creator)262 when(webdriver).Remote(command_executor=remote_url, options=options,263 desired_capabilities=capabilities,264 browser_profile=profile,265 file_detector=file_detector).thenReturn(expected_webdriver)266 driver = creator.create_headless_firefox({}, remote_url, None)267 assert driver == expected_webdriver268 assert options.headless is True269def test_ie(creator):270 expected_webdriver = mock()271 when(webdriver).Ie(options=None, service_log_path=None).thenReturn(expected_webdriver)272 driver = creator.create_ie({}, None)273 assert driver == expected_webdriver274 when(webdriver).Ie(capabilities={'key': 'value'}, options=None,275 service_log_path=None).thenReturn(expected_webdriver)276 driver = creator.create_ie(desired_capabilities={'capabilities': {'key': 'value'}}, remote_url=None,277 options=None, service_log_path=None)278 assert driver == expected_webdriver279def test_ie_remote_no_caps(creator):280 url = 'http://localhost:4444/wd/hub'281 expected_webdriver = mock()282 capabilities = webdriver.DesiredCapabilities.INTERNETEXPLORER.copy()283 file_detector = mock_file_detector(creator)284 when(webdriver).Remote(command_executor=url, browser_profile=None,285 desired_capabilities=capabilities, options=None,286 file_detector=file_detector).thenReturn(expected_webdriver)287 driver = creator.create_ie({}, url)288 assert driver == expected_webdriver289def test_ie_remote_caps(creator):290 url = 'http://localhost:4444/wd/hub'291 expected_webdriver = mock()292 capabilities = {"browserName": "internet explorer"}293 file_detector = mock_file_detector(creator)294 when(webdriver).Remote(command_executor=url, browser_profile=None,295 desired_capabilities=capabilities, options=None,296 file_detector=file_detector).thenReturn(expected_webdriver)297 driver = creator.create_ie({'capabilities': capabilities}, url)298 assert driver == expected_webdriver299def test_ie_no_browser_name(creator):300 url = 'http://localhost:4444/wd/hub'301 expected_webdriver = mock()302 capabilities = {'browserName': 'internet explorer', 'key': 'value'}303 file_detector = mock_file_detector(creator)304 when(webdriver).Remote(command_executor=url, browser_profile=None,305 desired_capabilities=capabilities, options=None,306 file_detector=file_detector).thenReturn(expected_webdriver)307 driver = creator.create_ie({'capabilities': {'key': 'value'}}, url)308 assert driver == expected_webdriver309def test_edge(creator):310 expected_webdriver = mock()311 when(webdriver).Edge(service_log_path=None).thenReturn(expected_webdriver)312 when(creator)._has_options(ANY).thenReturn(False)313 driver = creator.create_edge({}, None)314 assert driver == expected_webdriver315def test_edge_remote_no_caps(creator):316 url = 'http://localhost:4444/wd/hub'317 expected_webdriver = mock()318 capabilities = webdriver.DesiredCapabilities.EDGE.copy()319 file_detector = mock_file_detector(creator)320 when(webdriver).Remote(command_executor=url, browser_profile=None,321 desired_capabilities=capabilities, options=None,322 file_detector=file_detector).thenReturn(expected_webdriver)323 driver = creator.create_edge({}, url)324 assert driver == expected_webdriver325def test_edge_remote_caps(creator):326 url = 'http://localhost:4444/wd/hub'327 expected_webdriver = mock()328 capabilities = {"browserName": "MicrosoftEdge"}329 file_detector = mock_file_detector(creator)330 when(webdriver).Remote(command_executor=url, browser_profile=None,331 desired_capabilities=capabilities, options=None,332 file_detector=file_detector).thenReturn(expected_webdriver)333 driver = creator.create_edge({'capabilities': capabilities}, url)334 assert driver == expected_webdriver335def test_edge_no_browser_name(creator):336 url = 'http://localhost:4444/wd/hub'337 expected_webdriver = mock()338 capabilities = {'browserName': 'MicrosoftEdge', 'key': 'value'}339 file_detector = mock_file_detector(creator)340 when(webdriver).Remote(command_executor=url, browser_profile=None,341 desired_capabilities=capabilities, options=None,342 file_detector=file_detector).thenReturn(expected_webdriver)343 driver = creator.create_edge({'capabilities': {'key': 'value'}}, url)344 assert driver == expected_webdriver345def test_opera(creator):346 expected_webdriver = mock()347 when(webdriver).Opera(options=None, service_log_path=None).thenReturn(expected_webdriver)348 driver = creator.create_opera({}, None)349 assert driver == expected_webdriver350def test_opera_remote_no_caps(creator):351 url = 'http://localhost:4444/wd/hub'352 expected_webdriver = mock()353 capabilities = webdriver.DesiredCapabilities.OPERA.copy()354 file_detector = mock_file_detector(creator)355 when(webdriver).Remote(command_executor=url, browser_profile=None,356 desired_capabilities=capabilities,357 options=None, file_detector=file_detector).thenReturn(expected_webdriver)358 driver = creator.create_opera({}, url)359 assert driver == expected_webdriver360def test_opera_remote_caps(creator):361 url = 'http://localhost:4444/wd/hub'362 expected_webdriver = mock()363 capabilities = {"browserName": "opera"}364 file_detector = mock_file_detector(creator)365 when(webdriver).Remote(command_executor=url, browser_profile=None,366 desired_capabilities=capabilities,367 options=None, file_detector=file_detector).thenReturn(expected_webdriver)368 driver = creator.create_opera({'desired_capabilities': capabilities}, url)369 assert driver == expected_webdriver370def test_opera_no_browser_name(creator):371 url = 'http://localhost:4444/wd/hub'372 expected_webdriver = mock()373 capabilities = {'browserName': 'opera', 'key': 'value'}374 file_detector = mock_file_detector(creator)375 when(webdriver).Remote(command_executor=url, browser_profile=None,376 desired_capabilities=capabilities,377 options=None, file_detector=file_detector).thenReturn(expected_webdriver)378 driver = creator.create_opera({'desired_capabilities': {'key': 'value'}}, url)379 assert driver == expected_webdriver380def test_safari(creator):381 expected_webdriver = mock()382 when(webdriver).Safari().thenReturn(expected_webdriver)383 driver = creator.create_safari({}, None)384 assert driver == expected_webdriver385def test_safari_remote_no_caps(creator):386 url = 'http://localhost:4444/wd/hub'387 expected_webdriver = mock()388 file_detector = mock_file_detector(creator)389 capabilities = webdriver.DesiredCapabilities.SAFARI.copy()390 when(webdriver).Remote(command_executor=url, browser_profile=None,391 desired_capabilities=capabilities,392 options=None, file_detector=file_detector).thenReturn(expected_webdriver)393 driver = creator.create_safari({}, url)394 assert driver == expected_webdriver395def test_safari_remote_caps(creator):396 url = 'http://localhost:4444/wd/hub'397 expected_webdriver = mock()398 capabilities = {"browserName": "safari"}399 file_detector = mock_file_detector(creator)400 when(webdriver).Remote(command_executor=url, browser_profile=None,401 desired_capabilities=capabilities,402 options=None, file_detector=file_detector).thenReturn(expected_webdriver)403 driver = creator.create_safari({'desired_capabilities': capabilities}, url)404 assert driver == expected_webdriver405def test_safari_no_broser_name(creator):406 file_detector = mock_file_detector(creator)407 url = 'http://localhost:4444/wd/hub'408 expected_webdriver = mock()409 capabilities = {'browserName': 'safari', 'key': 'value'}410 when(webdriver).Remote(command_executor=url, browser_profile=None,411 desired_capabilities=capabilities,412 options=None, file_detector=file_detector).thenReturn(expected_webdriver)413 driver = creator.create_safari({'desired_capabilities': {'key': 'value'}}, url)414 assert driver == expected_webdriver415def test_phantomjs(creator):416 expected_webdriver = mock()417 when(webdriver).PhantomJS(service_log_path=None).thenReturn(expected_webdriver)418 driver = creator.create_phantomjs({}, None)419 assert driver == expected_webdriver420def test_phantomjs_remote_no_caps(creator):421 url = 'http://localhost:4444/wd/hub'422 expected_webdriver = mock()423 capabilities = webdriver.DesiredCapabilities.PHANTOMJS.copy()424 file_detector = mock_file_detector(creator)425 when(webdriver).Remote(command_executor=url, browser_profile=None,426 desired_capabilities=capabilities,427 options=None,428 file_detector=file_detector).thenReturn(expected_webdriver)429 driver = creator.create_phantomjs({}, url)430 assert driver == expected_webdriver431def test_phantomjs_remote_caps(creator):432 url = 'http://localhost:4444/wd/hub'433 expected_webdriver = mock()434 capabilities = {"browserName": "phantomjs"}435 file_detector = mock_file_detector(creator)436 when(webdriver).Remote(command_executor=url, browser_profile=None,437 desired_capabilities=capabilities,438 options=None,439 file_detector=file_detector).thenReturn(expected_webdriver)440 driver = creator.create_phantomjs({'desired_capabilities': capabilities}, url)441 assert driver == expected_webdriver442def test_phantomjs_no_browser_name(creator):443 url = 'http://localhost:4444/wd/hub'444 expected_webdriver = mock()445 capabilities = {'browserName': 'phantomjs', 'key': 'value'}446 file_detector = mock_file_detector(creator)447 when(webdriver).Remote(command_executor=url, browser_profile=None,448 desired_capabilities=capabilities,449 options=None, file_detector=file_detector).thenReturn(expected_webdriver)450 driver = creator.create_phantomjs({'desired_capabilities': {'key': 'value'}}, url)451 assert driver == expected_webdriver452def test_htmlunit_no_caps(creator):453 caps = webdriver.DesiredCapabilities.HTMLUNIT454 expected_webdriver = mock()455 file_detector = mock_file_detector(creator)456 when(webdriver).Remote(command_executor='None',457 desired_capabilities=caps,458 browser_profile=None, options=None,459 file_detector=file_detector).thenReturn(expected_webdriver)460 driver = creator.create_htmlunit({}, None)461 assert driver == expected_webdriver462def test_htmlunit_remote_caps(creator):463 caps = {"browserName": "htmlunit"}464 expected_webdriver = mock()465 file_detector = mock_file_detector(creator)466 when(webdriver).Remote(command_executor='None',467 desired_capabilities=caps,468 browser_profile=None, options=None,469 file_detector=file_detector).thenReturn(expected_webdriver)470 driver = creator.create_htmlunit({'desired_capabilities': caps}, None)471 assert driver == expected_webdriver472def test_htmlunit_no_browser_name(creator):473 capabilities = {'browserName': 'htmlunit', 'key': 'value'}474 expected_webdriver = mock()475 file_detector = mock_file_detector(creator)476 when(webdriver).Remote(command_executor='None',477 desired_capabilities=capabilities,478 browser_profile=None, options=None,479 file_detector=file_detector).thenReturn(expected_webdriver)480 driver = creator.create_htmlunit({'desired_capabilities': {'key': 'value'}}, None)481 assert driver == expected_webdriver482def test_htmlunit_with_js(creator):483 caps = webdriver.DesiredCapabilities.HTMLUNITWITHJS.copy()484 expected_webdriver = mock()485 file_detector = mock_file_detector(creator)486 when(webdriver).Remote(command_executor='None',487 desired_capabilities=caps,488 browser_profile=None, options=None,489 file_detector=file_detector).thenReturn(expected_webdriver)490 driver = creator.create_htmlunit_with_js({}, None)491 assert driver == expected_webdriver492def test_htmlunit_with_js_no_browser_name(creator):493 capabilities = {'browserName': 'htmlunit', 'key': 'value'}494 expected_webdriver = mock()495 file_detector = mock_file_detector(creator)496 when(webdriver).Remote(command_executor='None',497 desired_capabilities=capabilities,498 browser_profile=None, options=None,499 file_detector=file_detector).thenReturn(expected_webdriver)500 driver = creator.create_htmlunit_with_js({'desired_capabilities': {'key': 'value'}}, None)501 assert driver == expected_webdriver502def test_android(creator):503 caps = webdriver.DesiredCapabilities.ANDROID504 expected_webdriver = mock()505 file_detector = mock_file_detector(creator)506 when(webdriver).Remote(command_executor='None',507 desired_capabilities=caps,508 browser_profile=None, options=None,509 file_detector=file_detector).thenReturn(expected_webdriver)510 driver = creator.create_android({}, None)511 assert driver == expected_webdriver512def test_android_no_browser_name(creator):513 capabilities = {'browserName': 'android', 'key': 'value'}514 expected_webdriver = mock()515 file_detector = mock_file_detector(creator)516 when(webdriver).Remote(command_executor='None',517 desired_capabilities=capabilities,518 browser_profile=None, options=None,519 file_detector=file_detector).thenReturn(expected_webdriver)520 driver = creator.create_android({'desired_capabilities': {'key': 'value'}}, None)521 assert driver == expected_webdriver522def test_iphone(creator):523 caps = webdriver.DesiredCapabilities.IPHONE524 expected_webdriver = mock()525 file_detector = mock_file_detector(creator)526 when(webdriver).Remote(command_executor='None',527 desired_capabilities=caps,528 browser_profile=None, options=None,529 file_detector=file_detector).thenReturn(expected_webdriver)530 driver = creator.create_iphone({}, None)531 assert driver == expected_webdriver532def test_iphone_no_browser_name(creator):533 capabilities = {'browserName': 'iPhone', 'key': 'value'}534 expected_webdriver = mock()535 file_detector = mock_file_detector(creator)536 when(webdriver).Remote(command_executor='None',537 desired_capabilities=capabilities,538 browser_profile=None,539 options=None, file_detector=file_detector).thenReturn(expected_webdriver)540 driver = creator.create_iphone({'desired_capabilities': {'key': 'value'}}, None)541 assert driver == expected_webdriver542def test_create_driver_chrome(creator):543 expected_webdriver = mock()544 when(webdriver).Chrome(options=None, service_log_path=None).thenReturn(expected_webdriver)545 for browser in ['chrome', 'googlechrome', 'gc']:546 driver = creator.create_driver(browser, None, None)547 assert driver == expected_webdriver548def test_create_driver_firefox(creator):549 expected_webdriver = mock()550 profile = mock()551 when(webdriver).FirefoxProfile().thenReturn(profile)552 log_file = get_geckodriver_log()553 when(webdriver).Firefox(options=None, service_log_path=log_file,554 firefox_profile=profile).thenReturn(expected_webdriver)555 for browser in ['ff', 'firefox']:556 driver = creator.create_driver(browser, None, None, None)557 assert driver == expected_webdriver558def test_create_driver_ie(creator):559 expected_webdriver = mock()560 when(webdriver).Ie(options=None,561 service_log_path=None).thenReturn(expected_webdriver)562 for browser in ['ie', 'Internet Explorer']:563 driver = creator.create_driver(browser, None, None)564 assert driver == expected_webdriver565def get_geckodriver_log():566 return os.path.join(LOG_DIR, 'geckodriver-1.log')567def mock_file_detector(creator):568 file_detector = mock()569 when(creator)._get_sl_file_detector().thenReturn(file_detector)...

Full Screen

Full Screen

test_selenium_options_parser.py

Source:test_selenium_options_parser.py Github

copy

Full Screen

...143 url = 'http://localhost:4444/wd/hub'144 caps = webdriver.DesiredCapabilities.CHROME.copy()145 options = mock()146 expected_webdriver = mock()147 file_detector = self.mock_file_detector()148 when(webdriver).Remote(command_executor=url,149 desired_capabilities=caps,150 browser_profile=None, options=options,151 file_detector=file_detector).thenReturn(expected_webdriver)152 driver = self.creator.create_chrome({}, url, options=options)153 self.assertEqual(driver, expected_webdriver)154 def test_create_headless_chrome_with_options(self):155 options = mock()156 expected_webdriver = mock()157 when(webdriver).Chrome(service_log_path=None, options=options).thenReturn(expected_webdriver)158 driver = self.creator.create_headless_chrome({}, None, options=options)159 self.assertEqual(driver, expected_webdriver)160 def test_create_firefox_with_options(self):161 log_file = os.path.join(self.output_dir, 'geckodriver-1.log')162 options = mock()163 profile = mock()164 expected_webdriver = mock()165 when(webdriver).FirefoxProfile().thenReturn(profile)166 when(webdriver).Firefox(options=options, firefox_profile=profile,167 service_log_path=log_file).thenReturn(expected_webdriver)168 driver = self.creator.create_firefox({}, None, None, options=options)169 self.assertEqual(driver, expected_webdriver)170 def test_create_firefox_with_options_and_remote_url(self):171 url = 'http://localhost:4444/wd/hub'172 profile = mock()173 when(webdriver).FirefoxProfile().thenReturn(profile)174 caps = webdriver.DesiredCapabilities.FIREFOX.copy()175 options = mock()176 expected_webdriver = mock()177 file_detector = self.mock_file_detector()178 when(webdriver).Remote(command_executor=url,179 desired_capabilities=caps,180 browser_profile=profile, options=options,181 file_detector=file_detector).thenReturn(expected_webdriver)182 driver = self.creator.create_firefox({}, url, None, options=options)183 self.assertEqual(driver, expected_webdriver)184 def test_create_headless_firefox_with_options(self):185 log_file = os.path.join(self.output_dir, 'geckodriver-1.log')186 options = mock()187 profile = mock()188 expected_webdriver = mock()189 when(webdriver).FirefoxProfile().thenReturn(profile)190 when(webdriver).Firefox(options=options, firefox_profile=profile,191 service_log_path=log_file).thenReturn(expected_webdriver)192 driver = self.creator.create_headless_firefox({}, None, None, options=options)193 self.assertEqual(driver, expected_webdriver)194 def test_create_ie_with_options(self):195 options = mock()196 expected_webdriver = mock()197 when(webdriver).Ie(service_log_path=None, options=options).thenReturn(expected_webdriver)198 driver = self.creator.create_ie({}, None, options=options)199 self.assertEqual(driver, expected_webdriver)200 def test_create_ie_with_options_and_remote_url(self):201 url = 'http://localhost:4444/wd/hub'202 caps = webdriver.DesiredCapabilities.INTERNETEXPLORER.copy()203 options = mock()204 expected_webdriver = mock()205 file_detector = self.mock_file_detector()206 when(webdriver).Remote(command_executor=url,207 desired_capabilities=caps,208 browser_profile=None, options=options,209 file_detector=file_detector).thenReturn(expected_webdriver)210 driver = self.creator.create_ie({}, url, options=options)211 self.assertEqual(driver, expected_webdriver)212 def test_create_ie_with_options_and_log_path(self):213 options = mock()214 expected_webdriver = mock()215 when(webdriver).Ie(options=options, service_log_path=None).thenReturn(expected_webdriver)216 driver = self.creator.create_ie({}, None, options=options)217 self.assertEqual(driver, expected_webdriver)218 def test_has_options(self):219 self.assertTrue(self.creator._has_options(webdriver.Chrome))220 self.assertTrue(self.creator._has_options(webdriver.Firefox))221 self.assertTrue(self.creator._has_options(webdriver.Ie))222 self.assertFalse(self.creator._has_options(webdriver.Edge))223 self.assertTrue(self.creator._has_options(webdriver.Opera))224 self.assertFalse(self.creator._has_options(webdriver.Safari))225 @unittest.skipIf('options' not in inspect.getargspec(webdriver.Edge.__init__), "Requires Selenium 4.0.")226 def test_create_edge_with_options(self):227 # TODO: This test requires Selenium 4.0 in Travis228 options = mock()229 expected_webdriver = mock()230 when(self.creator)._has_options(ANY).thenReturn(True)231 when(webdriver).Edge(service_log_path=None, options=options).thenReturn(expected_webdriver)232 driver = self.creator.create_edge({}, None, options=options)233 self.assertEqual(driver, expected_webdriver)234 def test_create_opera_with_options(self):235 options = mock()236 expected_webdriver = mock()237 when(webdriver).Opera(options=options, service_log_path=None).thenReturn(expected_webdriver)238 driver = self.creator.create_opera({}, None, options=options)239 self.assertEqual(driver, expected_webdriver)240 def test_create_opera_with_options_and_remote_url(self):241 url = 'http://localhost:4444/wd/hub'242 caps = webdriver.DesiredCapabilities.OPERA.copy()243 options = mock()244 expected_webdriver = mock()245 file_detector = self.mock_file_detector()246 when(webdriver).Remote(command_executor=url,247 desired_capabilities=caps,248 browser_profile=None, options=options,249 file_detector=file_detector).thenReturn(expected_webdriver)250 driver = self.creator.create_opera({}, url, options=options)251 self.assertEqual(driver, expected_webdriver)252 def test_create_safari_no_options_support(self):253 options = mock()254 expected_webdriver = mock()255 when(webdriver).Safari().thenReturn(expected_webdriver)256 driver = self.creator.create_safari({}, None, options=options)257 self.assertEqual(driver, expected_webdriver)258 def test_create_phantomjs_no_options_support(self):259 options = mock()260 expected_webdriver = mock()261 when(webdriver).PhantomJS(service_log_path=None).thenReturn(expected_webdriver)262 driver = self.creator.create_phantomjs({}, None, options=options)263 self.assertEqual(driver, expected_webdriver)264 def test_create_htmlunit_no_options_support(self):265 caps = webdriver.DesiredCapabilities.HTMLUNIT.copy()266 options = mock()267 expected_webdriver = mock()268 file_detector = self.mock_file_detector()269 when(webdriver).Remote(command_executor='None',270 desired_capabilities=caps,271 browser_profile=None, options=options,272 file_detector=file_detector).thenReturn(expected_webdriver)273 driver = self.creator.create_htmlunit({'desired_capabilities': caps}, None, options=options)274 self.assertEqual(driver, expected_webdriver)275 def test_create_htmlunit_with_js_no_options_support(self):276 caps = webdriver.DesiredCapabilities.HTMLUNITWITHJS.copy()277 options = mock()278 expected_webdriver = mock()279 file_detector = self.mock_file_detector()280 when(webdriver).Remote(command_executor='None',281 desired_capabilities=caps,282 browser_profile=None, options=options,283 file_detector=file_detector).thenReturn(expected_webdriver)284 driver = self.creator.create_htmlunit_with_js({}, None, options=options)285 self.assertEqual(driver, expected_webdriver)286 def test_android_options_support(self):287 caps = webdriver.DesiredCapabilities.ANDROID.copy()288 options = mock()289 expected_webdriver = mock()290 file_detector = self.mock_file_detector()291 when(webdriver).Remote(command_executor='None',292 desired_capabilities=caps,293 browser_profile=None, options=options,294 file_detector=file_detector).thenReturn(expected_webdriver)295 driver = self.creator.create_android({}, None, options=options)296 self.assertEqual(driver, expected_webdriver)297 def test_iphone_options_support(self):298 caps = webdriver.DesiredCapabilities.IPHONE.copy()299 options = mock()300 expected_webdriver = mock()301 file_detector = self.mock_file_detector()302 when(webdriver).Remote(command_executor='None',303 desired_capabilities=caps,304 browser_profile=None, options=options,305 file_detector=file_detector).thenReturn(expected_webdriver)306 driver = self.creator.create_iphone({}, None, options=options)307 self.assertEqual(driver, expected_webdriver)308 def test_create_driver_chrome(self):309 str_options = 'add_argument:--disable-dev-shm-usage'310 options = mock()311 expected_webdriver = mock()312 when(self.creator.selenium_options).create('chrome', str_options).thenReturn(options)313 when(webdriver).Chrome(service_log_path=None, options=options).thenReturn(expected_webdriver)314 driver = self.creator.create_driver('Chrome', desired_capabilities={}, remote_url=None,315 options=str_options)316 self.assertEqual(driver, expected_webdriver)317 def test_create_driver_firefox(self):318 log_file = os.path.join(self.output_dir, 'geckodriver-1.log')319 str_options = 'add_argument:--disable-dev-shm-usage'320 options = mock()321 profile = mock()322 when(webdriver).FirefoxProfile().thenReturn(profile)323 expected_webdriver = mock()324 when(self.creator.selenium_options).create('firefox', str_options).thenReturn(options)325 when(webdriver).Firefox(options=options, firefox_profile=profile,326 service_log_path=log_file).thenReturn(expected_webdriver)327 driver = self.creator.create_driver('FireFox', desired_capabilities={}, remote_url=None,328 options=str_options)329 self.assertEqual(driver, expected_webdriver)330 def mock_file_detector(self):331 file_detector = mock()332 when(self.creator)._get_sl_file_detector().thenReturn(file_detector)...

Full Screen

Full Screen

test_webdrivercreator_executable_path.py

Source:test_webdrivercreator_executable_path.py Github

copy

Full Screen

...42def test_create_chrome_executable_path_and_remote(creator):43 url = "http://localhost:4444/wd/hub"44 expected_webdriver = mock()45 capabilities = webdriver.DesiredCapabilities.CHROME.copy()46 file_detector = mock_file_detector(creator)47 when(webdriver).Remote(48 command_executor=url,49 browser_profile=None,50 desired_capabilities=capabilities,51 options=None,52 file_detector=file_detector,53 ).thenReturn(expected_webdriver)54 driver = creator.create_chrome({}, url, executable_path="/path/to/chromedriver")55 assert driver == expected_webdriver56def test_create_heasless_chrome_executable_path_set(creator):57 expected_webdriver = mock()58 options = mock()59 when(webdriver).ChromeOptions().thenReturn(options)60 when(webdriver).Chrome(61 options=options, service_log_path=None, executable_path="/path/to/chromedriver"62 ).thenReturn(expected_webdriver)63 driver = creator.create_headless_chrome(64 {}, None, executable_path="/path/to/chromedriver"65 )66 assert driver == expected_webdriver67def test_create_firefox_executable_path_set(creator):68 executable = "/path/to/geckodriver"69 expected_webdriver = mock()70 profile = mock()71 when(webdriver).FirefoxProfile().thenReturn(profile)72 log_file = get_geckodriver_log()73 when(webdriver).Firefox(74 options=None,75 firefox_profile=profile,76 service_log_path=log_file,77 executable_path=executable,78 ).thenReturn(expected_webdriver)79 driver = creator.create_firefox(80 {}, None, None, service_log_path=log_file, executable_path=executable81 )82 assert driver == expected_webdriver83def test_create_firefox_executable_path_not_set(creator):84 executable = "geckodriver"85 expected_webdriver = mock()86 profile = mock()87 when(webdriver).FirefoxProfile().thenReturn(profile)88 log_file = get_geckodriver_log()89 when(creator)._get_executable_path(ANY).thenReturn(executable)90 when(webdriver).Firefox(91 options=None,92 firefox_profile=profile,93 service_log_path=log_file,94 executable_path=executable,95 ).thenReturn(expected_webdriver)96 driver = creator.create_firefox(97 {}, None, None, service_log_path=log_file, executable_path=None98 )99 assert driver == expected_webdriver100def test_create_firefox_executable_path_and_remote(creator):101 url = "http://localhost:4444/wd/hub"102 expected_webdriver = mock()103 capabilities = webdriver.DesiredCapabilities.FIREFOX.copy()104 file_detector = mock_file_detector(creator)105 profile = mock()106 when(webdriver).FirefoxProfile().thenReturn(profile)107 when(webdriver).Remote(108 command_executor=url,109 browser_profile=profile,110 desired_capabilities=capabilities,111 options=None,112 file_detector=file_detector,113 ).thenReturn(expected_webdriver)114 driver = creator.create_firefox(115 {}, url, None, executable_path="/path/to/chromedriver"116 )117 assert driver == expected_webdriver118def test_create_headless_firefox_executable_path_set(creator):119 executable = "/path/to/geckodriver"120 expected_webdriver = mock()121 profile = mock()122 when(webdriver).FirefoxProfile().thenReturn(profile)123 log_file = get_geckodriver_log()124 options = mock()125 when(webdriver).FirefoxOptions().thenReturn(options)126 when(webdriver).Firefox(127 options=options,128 firefox_profile=profile,129 service_log_path=log_file,130 executable_path=executable,131 ).thenReturn(expected_webdriver)132 driver = creator.create_headless_firefox(133 {}, None, None, service_log_path=log_file, executable_path=executable134 )135 assert driver == expected_webdriver136def test_create_ie_executable_path_set(creator):137 executable_path = "/path/to/IEDriverServer.exe"138 expected_webdriver = mock()139 when(webdriver).Ie(140 options=None, service_log_path=None, executable_path=executable_path141 ).thenReturn(expected_webdriver)142 driver = creator.create_ie({}, None, executable_path=executable_path)143 assert driver == expected_webdriver144def test_create_ie_executable_path_not_set(creator):145 executable_path = "IEDriverServer.exe"146 expected_webdriver = mock()147 when(creator)._get_executable_path(ANY).thenReturn(executable_path)148 when(webdriver).Ie(149 options=None, service_log_path=None, executable_path=executable_path150 ).thenReturn(expected_webdriver)151 driver = creator.create_ie({}, None, executable_path=None)152 assert driver == expected_webdriver153def test_create_edge_executable_path_set(creator):154 executable_path = "/path/to/MicrosoftWebDriver.exe"155 expected_webdriver = mock()156 when(creator)._has_options(ANY).thenReturn(False)157 when(webdriver).Edge(158 service_log_path=None, executable_path=executable_path159 ).thenReturn(expected_webdriver)160 driver = creator.create_edge({}, None, executable_path=executable_path)161 assert driver == expected_webdriver162def test_create_edge_executable_path_not_set(creator):163 executable_path = "MicrosoftWebDriver.exe"164 expected_webdriver = mock()165 when(creator)._get_executable_path(ANY).thenReturn(executable_path)166 when(creator)._has_options(ANY).thenReturn(False)167 when(webdriver).Edge(168 service_log_path=None, executable_path=executable_path169 ).thenReturn(expected_webdriver)170 driver = creator.create_edge({}, None, executable_path=None)171 assert driver == expected_webdriver172def test_create_opera_executable_path_set(creator):173 executable_path = "/path/to/operadriver"174 expected_webdriver = mock()175 when(webdriver).Opera(176 service_log_path=None, options=None, executable_path=executable_path177 ).thenReturn(expected_webdriver)178 driver = creator.create_opera({}, None, executable_path=executable_path)179 assert driver == expected_webdriver180def test_create_opera_executable_path_not_set(creator):181 executable_path = "operadriver"182 expected_webdriver = mock()183 when(creator)._get_executable_path(ANY).thenReturn(executable_path)184 when(webdriver).Opera(185 service_log_path=None, options=None, executable_path=executable_path186 ).thenReturn(expected_webdriver)187 driver = creator.create_opera({}, None, executable_path=None)188 assert driver == expected_webdriver189def test_create_safari_executable_path_set(creator):190 executable_path = "/path/to/safaridriver"191 expected_webdriver = mock()192 when(webdriver).Safari(executable_path=executable_path).thenReturn(193 expected_webdriver194 )195 driver = creator.create_safari({}, None, executable_path=executable_path)196 assert driver == expected_webdriver197def test_create_safari_executable_path_not_set(creator):198 executable_path = "/usr/bin/safaridriver"199 expected_webdriver = mock()200 when(creator)._get_executable_path(ANY).thenReturn(executable_path)201 when(webdriver).Safari(executable_path=executable_path).thenReturn(202 expected_webdriver203 )204 driver = creator.create_safari({}, None, executable_path=None)205 assert driver == expected_webdriver206def test_create_phantomjs_executable_path_set(creator):207 executable_path = "/path/to/phantomjs"208 expected_webdriver = mock()209 when(webdriver).PhantomJS(210 service_log_path=None, executable_path=executable_path211 ).thenReturn(expected_webdriver)212 driver = creator.create_phantomjs({}, None, executable_path=executable_path)213 assert driver == expected_webdriver214def test_create_phantomjs_executable_path_not_set(creator):215 executable_path = "phantomjs"216 expected_webdriver = mock()217 when(creator)._get_executable_path(ANY).thenReturn(executable_path)218 when(webdriver).PhantomJS(219 service_log_path=None, executable_path=executable_path220 ).thenReturn(expected_webdriver)221 driver = creator.create_phantomjs({}, None, executable_path=None)222 assert driver == expected_webdriver223def test_create_htmlunit_executable_path_set(creator):224 executable_path = "path/to/bin"225 caps = webdriver.DesiredCapabilities.HTMLUNIT.copy()226 expected_webdriver = mock()227 file_detector = mock_file_detector(creator)228 when(webdriver).Remote(229 command_executor="None",230 desired_capabilities=caps,231 browser_profile=None,232 options=None,233 file_detector=file_detector,234 ).thenReturn(expected_webdriver)235 driver = creator.create_htmlunit({}, None, executable_path=executable_path)236 assert driver == expected_webdriver237def test_create_htmlunit_with_js_executable_path_set(creator):238 executable_path = "path/to/bin"239 caps = webdriver.DesiredCapabilities.HTMLUNITWITHJS.copy()240 expected_webdriver = mock()241 file_detector = mock_file_detector(creator)242 when(webdriver).Remote(243 command_executor="None",244 desired_capabilities=caps,245 browser_profile=None,246 options=None,247 file_detector=file_detector,248 ).thenReturn(expected_webdriver)249 driver = creator.create_htmlunit_with_js({}, None, executable_path=executable_path)250 assert driver == expected_webdriver251def test_create_android_executable_path_set(creator):252 executable_path = "path/to/bin"253 caps = webdriver.DesiredCapabilities.ANDROID.copy()254 expected_webdriver = mock()255 file_detector = mock_file_detector(creator)256 when(webdriver).Remote(257 command_executor="None",258 desired_capabilities=caps,259 browser_profile=None,260 options=None,261 file_detector=file_detector,262 ).thenReturn(expected_webdriver)263 driver = creator.create_android({}, None, executable_path=executable_path)264 assert driver == expected_webdriver265def test_create_iphone_executable_path_set(creator):266 executable_path = "path/to/bin"267 caps = webdriver.DesiredCapabilities.IPHONE.copy()268 expected_webdriver = mock()269 file_detector = mock_file_detector(creator)270 when(webdriver).Remote(271 command_executor="None",272 desired_capabilities=caps,273 browser_profile=None,274 options=None,275 file_detector=file_detector,276 ).thenReturn(expected_webdriver)277 driver = creator.create_iphone({}, None, executable_path=executable_path)278 assert driver == expected_webdriver279def test_open_browser_executable_path_set(creator):280 expected_webdriver = mock()281 when(webdriver).Chrome(282 options=None, service_log_path=None, executable_path="/path/to/chromedriver"283 ).thenReturn(expected_webdriver)284 driver = creator.create_driver(285 "Chrome", {}, None, executable_path="/path/to/chromedriver"286 )287 assert driver == expected_webdriver288def mock_file_detector(creator):289 file_detector = mock()290 when(creator)._get_sl_file_detector().thenReturn(file_detector)291 return file_detector292def get_geckodriver_log():...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumLibrary automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful