How to use _create_remote_driver method in toolium

Best Python code snippet using toolium_python

test_config_driver.py

Source:test_config_driver.py Github

copy

Full Screen

...254 # Firefox profile mock255 class ProfileMock(object):256 encoded = 'encoded profile'257 config_driver._create_firefox_profile = mock.MagicMock(return_value=ProfileMock())258 config_driver._create_remote_driver()259 capabilities = DesiredCapabilities.FIREFOX.copy()260 capabilities['firefox_profile'] = 'encoded profile'261 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,262 desired_capabilities=capabilities)263@mock.patch('toolium.config_driver.webdriver')264def test_create_remote_driver_chrome(webdriver_mock, config, utils):265 config.set('Driver', 'type', 'chrome')266 server_url = 'http://10.20.30.40:5555'267 utils.get_server_url.return_value = server_url268 utils.get_driver_name.return_value = 'chrome'269 config_driver = ConfigDriver(config, utils)270 # Chrome options mock271 chrome_options = mock.MagicMock()272 chrome_options.to_capabilities.return_value = {'goog:chromeOptions': 'chrome options'}273 config_driver._create_chrome_options = mock.MagicMock(return_value=chrome_options)274 config_driver._create_remote_driver()275 capabilities = DesiredCapabilities.CHROME.copy()276 capabilities['goog:chromeOptions'] = 'chrome options'277 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,278 desired_capabilities=capabilities)279@mock.patch('toolium.config_driver.webdriver')280def test_create_remote_driver_chrome_multiple_options(webdriver_mock, config, utils):281 # From goog:chromeOptions in Capabilities section282 options_from_capabilities = {283 'excludeSwitches': ['enable-automation'], 'useAutomationExtension': False,284 'prefs': {'download.default_directory': '/this_value_will_be_overwritten',285 'download.prompt_for_download': False}286 }287 # From ChromePreferences, ChromeMobileEmulation, ChromeArguments and Chrome sections288 options_from_sections = {289 'prefs': {'download.default_directory': '/tmp'},290 'mobileEmulation': {'deviceName': 'Google Nexus 5'},291 'args': ['user-data-dir=C:\\Users\\USERNAME\\AppData\\Local\\Google\\Chrome\\User Data'],292 'binary': '/usr/local/chrome_beta/chrome'293 }294 # Merged chrome options295 final_chrome_options = {296 'excludeSwitches': ['enable-automation'], 'useAutomationExtension': False,297 'prefs': {'download.default_directory': '/tmp', 'download.prompt_for_download': False},298 'mobileEmulation': {'deviceName': 'Google Nexus 5'},299 'args': ['user-data-dir=C:\\Users\\USERNAME\\AppData\\Local\\Google\\Chrome\\User Data'],300 'binary': '/usr/local/chrome_beta/chrome'301 }302 config.set('Driver', 'type', 'chrome')303 config.add_section('Capabilities')304 config.set('Capabilities', 'goog:chromeOptions', str(options_from_capabilities))305 server_url = 'http://10.20.30.40:5555'306 utils.get_server_url.return_value = server_url307 utils.get_driver_name.return_value = 'chrome'308 config_driver = ConfigDriver(config, utils)309 # Chrome options mock310 chrome_options = mock.MagicMock()311 chrome_options.to_capabilities.return_value = {'goog:chromeOptions': options_from_sections}312 config_driver._create_chrome_options = mock.MagicMock(return_value=chrome_options)313 config_driver._create_remote_driver()314 capabilities = DesiredCapabilities.CHROME.copy()315 capabilities['goog:chromeOptions'] = final_chrome_options316 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,317 desired_capabilities=capabilities)318@mock.patch('toolium.config_driver.webdriver')319def test_create_remote_driver_chrome_old_selenium(webdriver_mock, config, utils):320 config.set('Driver', 'type', 'chrome')321 server_url = 'http://10.20.30.40:5555'322 utils.get_server_url.return_value = server_url323 utils.get_driver_name.return_value = 'chrome'324 config_driver = ConfigDriver(config, utils)325 # Chrome options mock326 chrome_options = mock.MagicMock()327 chrome_options.to_capabilities.return_value = {'chromeOptions': 'chrome options'}328 config_driver._create_chrome_options = mock.MagicMock(return_value=chrome_options)329 config_driver._create_remote_driver()330 capabilities = DesiredCapabilities.CHROME.copy()331 capabilities['chromeOptions'] = 'chrome options'332 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,333 desired_capabilities=capabilities)334@mock.patch('toolium.config_driver.webdriver')335def test_create_remote_driver_safari(webdriver_mock, config, utils):336 config.set('Driver', 'type', 'safari')337 server_url = 'http://10.20.30.40:5555'338 utils.get_server_url.return_value = server_url339 utils.get_driver_name.return_value = 'safari'340 config_driver = ConfigDriver(config, utils)341 config_driver._create_remote_driver()342 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,343 desired_capabilities=DesiredCapabilities.SAFARI)344@mock.patch('toolium.config_driver.webdriver')345def test_create_remote_driver_opera(webdriver_mock, config, utils):346 config.set('Driver', 'type', 'opera')347 server_url = 'http://10.20.30.40:5555'348 utils.get_server_url.return_value = server_url349 utils.get_driver_name.return_value = 'opera'350 config_driver = ConfigDriver(config, utils)351 config_driver._create_remote_driver()352 capabilities = DesiredCapabilities.OPERA353 capabilities['opera.autostart'] = True354 capabilities['opera.arguments'] = '-fullscreen'355 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,356 desired_capabilities=capabilities)357@mock.patch('toolium.config_driver.webdriver')358def test_create_remote_driver_iexplore(webdriver_mock, config, utils):359 config.set('Driver', 'type', 'iexplore')360 server_url = 'http://10.20.30.40:5555'361 utils.get_server_url.return_value = server_url362 utils.get_driver_name.return_value = 'iexplore'363 config_driver = ConfigDriver(config, utils)364 config_driver._create_remote_driver()365 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,366 desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)367@mock.patch('toolium.config_driver.webdriver')368def test_create_remote_driver_edge(webdriver_mock, config, utils):369 config.set('Driver', 'type', 'edge')370 server_url = 'http://10.20.30.40:5555'371 utils.get_server_url.return_value = server_url372 utils.get_driver_name.return_value = 'edge'373 config_driver = ConfigDriver(config, utils)374 config_driver._create_remote_driver()375 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,376 desired_capabilities=DesiredCapabilities.EDGE)377@mock.patch('toolium.config_driver.webdriver')378def test_create_remote_driver_phantomjs(webdriver_mock, config, utils):379 config.set('Driver', 'type', 'phantomjs')380 server_url = 'http://10.20.30.40:5555'381 utils.get_server_url.return_value = server_url382 utils.get_driver_name.return_value = 'phantomjs'383 config_driver = ConfigDriver(config, utils)384 config_driver._create_remote_driver()385 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,386 desired_capabilities=DesiredCapabilities.PHANTOMJS)387@mock.patch('toolium.config_driver.appiumdriver')388def test_create_remote_driver_android(appiumdriver_mock, config, utils):389 config.set('Driver', 'type', 'android')390 config.add_section('AppiumCapabilities')391 config.set('AppiumCapabilities', 'automationName', 'Appium')392 config.set('AppiumCapabilities', 'platformName', 'Android')393 server_url = 'http://10.20.30.40:5555'394 utils.get_server_url.return_value = server_url395 utils.get_driver_name.return_value = 'android'396 config_driver = ConfigDriver(config, utils)397 config_driver._create_remote_driver()398 capabilities = {'automationName': 'Appium', 'platformName': 'Android'}399 appiumdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,400 desired_capabilities=capabilities)401@mock.patch('toolium.config_driver.appiumdriver')402def test_create_remote_driver_ios(appiumdriver_mock, config, utils):403 config.set('Driver', 'type', 'ios')404 config.add_section('AppiumCapabilities')405 config.set('AppiumCapabilities', 'automationName', 'Appium')406 config.set('AppiumCapabilities', 'platformName', 'iOS')407 server_url = 'http://10.20.30.40:5555'408 utils.get_server_url.return_value = server_url409 utils.get_driver_name.return_value = 'ios'410 config_driver = ConfigDriver(config, utils)411 config_driver._create_remote_driver()412 capabilities = {'automationName': 'Appium', 'platformName': 'iOS'}413 appiumdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,414 desired_capabilities=capabilities)415@mock.patch('toolium.config_driver.appiumdriver')416def test_create_remote_driver_iphone(appiumdriver_mock, config):417 config.set('Driver', 'type', 'iphone')418 config.add_section('AppiumCapabilities')419 config.set('AppiumCapabilities', 'automationName', 'Appium')420 config.set('AppiumCapabilities', 'platformName', 'iOS')421 server_url = 'http://10.20.30.40:5555'422 utils = mock.MagicMock()423 utils.get_server_url.return_value = server_url424 utils.get_driver_name.return_value = 'iphone'425 config_driver = ConfigDriver(config, utils)426 config_driver._create_remote_driver()427 capabilities = {'automationName': 'Appium', 'platformName': 'iOS'}428 appiumdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,429 desired_capabilities=capabilities)430@mock.patch('toolium.config_driver.webdriver')431def test_create_remote_driver_version_platform(webdriver_mock, config, utils):432 config.set('Driver', 'type', 'iexplore-11-on-WIN10')433 server_url = 'http://10.20.30.40:5555'434 utils.get_server_url.return_value = server_url435 utils.get_driver_name.return_value = 'iexplore'436 config_driver = ConfigDriver(config, utils)437 config_driver._create_remote_driver()438 capabilities = DesiredCapabilities.INTERNETEXPLORER439 capabilities['version'] = '11'440 capabilities['platform'] = 'WIN10'441 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,442 desired_capabilities=capabilities)443@mock.patch('toolium.config_driver.webdriver')444def test_create_remote_driver_version(webdriver_mock, config, utils):445 config.set('Driver', 'type', 'iexplore-11')446 server_url = 'http://10.20.30.40:5555'447 utils.get_server_url.return_value = server_url448 utils.get_driver_name.return_value = 'iexplore'449 config_driver = ConfigDriver(config, utils)450 config_driver._create_remote_driver()451 capabilities = DesiredCapabilities.INTERNETEXPLORER.copy()452 capabilities['version'] = '11'453 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,454 desired_capabilities=capabilities)455@mock.patch('toolium.config_driver.webdriver')456def test_create_remote_driver_capabilities(webdriver_mock, config, utils):457 config.set('Driver', 'type', 'iexplore-11')458 config.add_section('Capabilities')459 config.set('Capabilities', 'version', '11')460 server_url = 'http://10.20.30.40:5555'461 utils.get_server_url.return_value = server_url462 utils.get_driver_name.return_value = 'iexplore'463 config_driver = ConfigDriver(config, utils)464 config_driver._create_remote_driver()465 capabilities = DesiredCapabilities.INTERNETEXPLORER.copy()466 capabilities['version'] = '11'467 webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,468 desired_capabilities=capabilities)469def test_convert_property_type_true(config, utils):470 config_driver = ConfigDriver(config, utils)471 value = 'True'472 assert config_driver._convert_property_type(value) is True473def test_convert_property_type_false(config, utils):474 config_driver = ConfigDriver(config, utils)475 value = 'False'476 assert config_driver._convert_property_type(value) is False477def test_convert_property_type_dict(config, utils):478 config_driver = ConfigDriver(config, utils)...

Full Screen

Full Screen

driver.py

Source:driver.py Github

copy

Full Screen

...63 DriverFactory.DRIVER_IPHONE | DriverFactory.DRIVER_IPAD64 """65 logger.info('Creating driver')66 if driver_type == self.TYPE_REMOTE:67 instance = self._create_remote_driver(driver, **kwargs)68 else:69 instance = self._create_local_driver(driver, **kwargs)70 try:71 instance.maximize_window()72 except:73 datetime.time.sleep(10)74 try:75 instance.maximize_window()76 except Exception:77 raise78 return instance79 def _create_local_driver(self, driver, **kwargs):80 logger.debug('Creating local driver "%s"', driver)81 try:82 return self.LOCAL_DRIVERS[driver](self)(**kwargs)83 except KeyError:84 raise TypeError("Unsupported Driver Type {0}".format(driver))85 def _create_remote_driver(self, driver, **kwargs):86 if not 'remote_url' in kwargs:87 raise ValueError('Remote drivers require the declaration of a remote_url')88 remote_url = kwargs.get('remote_url')89 logger.info('Creating remot driver "%s" (remote_url=%s)', driver, remote_url)90 try:91 # Get a copy of the desired capabilities object. (to avoid overwriting the global.)92 capabilities = self.DRIVER_CAPABILITIES[driver].copy()93 except KeyError:94 raise TypeError("Unsupported Browser Type {0}".format(driver))95 if 'capabilities' in kwargs:96 for c in kwargs.get('capabilities'):97 capabilities.update(c)98 if 'proxy' in kwargs:99 proxy_url = kwargs.get('proxy')...

Full Screen

Full Screen

web_driver_factory.py

Source:web_driver_factory.py Github

copy

Full Screen

...21 """22 Create web driver.23 """24 if self._config.get_bool(WellKnownConfigKeys.SELENIUM_REMOTE):25 return self._create_remote_driver()26 driver_type = self._config.get(WellKnownConfigKeys.SELENIUM_DRIVER)27 if driver_type == WebDriverFactory.WEB_DRIVER_TYPE_CHROME:28 return self._create_chrome_driver()29 if driver_type == WebDriverFactory.WEB_DRIVER_TYPE_FIREFOX:30 return self._create_firefox_driver()31 raise TestError('Unknown web driver type "{}"'.format(driver_type))32 def _create_remote_driver(self) -> WebDriver:33 """34 Create remote driver.35 :return: web driver.36 """37 remote_uri = self._config.get(WellKnownConfigKeys.SELENIUM_REMOTE_URI)38 if remote_uri is None:39 raise TestError('{} is missing'.format(WellKnownConfigKeys.SELENIUM_REMOTE_URI))40 driver_type = self._config.get(WellKnownConfigKeys.SELENIUM_DRIVER)41 if driver_type == WebDriverFactory.WEB_DRIVER_TYPE_CHROME:42 desired_capabilities = DesiredCapabilities.CHROME43 elif driver_type == WebDriverFactory.WEB_DRIVER_TYPE_FIREFOX:44 desired_capabilities = DesiredCapabilities.FIREFOX45 else:46 raise TestError('Unknown web driver type "{}"'.format(driver_type))...

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 toolium 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