Exemplo n.º 1
0
    def test_create_local_driver_unknown_driver(self):
        self.config.set('Driver', 'type', 'unknown')
        config_driver = ConfigDriver(self.config)

        with assert_raises(Exception) as cm:
            config_driver._create_local_driver()
        assert_equal('Unknown driver unknown', str(cm.exception))
Exemplo n.º 2
0
def test_create_local_driver_unknown_driver(config):
    config.set('Driver', 'type', 'unknown')
    config_driver = ConfigDriver(config)

    with pytest.raises(Exception) as excinfo:
        config_driver._create_local_driver()
    assert 'Unknown driver unknown' == str(excinfo.value)
Exemplo n.º 3
0
    def test_create_local_driver_iphone(self):
        self.config.set('Driver', 'type', 'iphone')
        config_driver = ConfigDriver(self.config)
        config_driver._create_remote_driver = lambda: 'remote driver mock'

        driver = config_driver._create_local_driver()
        assert_equal(driver, 'remote driver mock')
Exemplo n.º 4
0
def test_create_local_driver_edge(webdriver_mock, config):
    config.set('Driver', 'type', 'edge')
    config.set('Driver', 'edge_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)

    config_driver._create_local_driver()
    webdriver_mock.Edge.assert_called_once_with('/tmp/driver', capabilities=DesiredCapabilities.EDGE)
Exemplo n.º 5
0
def test_create_local_driver_safari(webdriver_mock, config):
    config.set('Driver', 'type', 'safari')
    config_driver = ConfigDriver(config)

    config_driver._create_local_driver()
    webdriver_mock.Safari.assert_called_once_with(
        desired_capabilities=DesiredCapabilities.SAFARI)
Exemplo n.º 6
0
def test_create_local_driver_safari(webdriver_mock, config, utils):
    config.set('Driver', 'type', 'safari')
    utils.get_driver_name.return_value = 'safari'
    config_driver = ConfigDriver(config, utils)

    config_driver._create_local_driver()
    webdriver_mock.Safari.assert_called_once_with(desired_capabilities=DesiredCapabilities.SAFARI)
Exemplo n.º 7
0
def test_create_local_driver_edge(webdriver_mock, config):
    config.set('Driver', 'type', 'edge')
    config.set('Driver', 'edge_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)

    config_driver._create_local_driver()
    webdriver_mock.Edge.assert_called_once_with('/tmp/driver', capabilities=DesiredCapabilities.EDGE)
Exemplo n.º 8
0
def test_create_local_driver_iexplore(webdriver_mock, config):
    config.set('Driver', 'type', 'iexplore')
    config.set('Driver', 'explorer_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)

    config_driver._create_local_driver()
    webdriver_mock.Ie.assert_called_once_with('/tmp/driver', capabilities=DesiredCapabilities.INTERNETEXPLORER)
Exemplo n.º 9
0
def test_create_local_driver_iexplore(webdriver_mock, config):
    config.set('Driver', 'type', 'iexplore')
    config.set('Driver', 'explorer_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)

    config_driver._create_local_driver()
    webdriver_mock.Ie.assert_called_once_with('/tmp/driver', capabilities=DesiredCapabilities.INTERNETEXPLORER)
Exemplo n.º 10
0
def test_create_local_driver_iphone(config):
    config.set('Driver', 'type', 'iphone')
    config_driver = ConfigDriver(config)
    config_driver._create_remote_driver = lambda: 'remote driver mock'

    driver = config_driver._create_local_driver()
    assert driver == 'remote driver mock'
Exemplo n.º 11
0
def test_create_local_driver_unknown_driver(config):
    config.set('Driver', 'type', 'unknown')
    config_driver = ConfigDriver(config)

    with pytest.raises(Exception) as excinfo:
        config_driver._create_local_driver()
    assert 'Unknown driver unknown' == str(excinfo.value)
Exemplo n.º 12
0
def test_create_local_driver_iphone(config):
    config.set('Driver', 'type', 'iphone')
    config_driver = ConfigDriver(config)
    config_driver._create_remote_driver = lambda: 'remote driver mock'

    driver = config_driver._create_local_driver()
    assert driver == 'remote driver mock'
Exemplo n.º 13
0
def test_create_local_driver_edge(webdriver_mock, config, utils):
    config.set('Driver', 'type', 'edge')
    config.set('Driver', 'edge_driver_path', '/tmp/driver')
    utils.get_driver_name.return_value = 'edge'
    config_driver = ConfigDriver(config, utils)

    config_driver._create_local_driver()
    webdriver_mock.Edge.assert_called_once_with('/tmp/driver', capabilities=DesiredCapabilities.EDGE)
Exemplo n.º 14
0
def test_create_local_driver_iphone(config, utils):
    config.set('Driver', 'type', 'iphone')
    utils.get_driver_name.return_value = 'iphone'
    config_driver = ConfigDriver(config, utils)
    config_driver._create_remote_driver = lambda: 'remote driver mock'

    driver = config_driver._create_local_driver()
    assert driver == 'remote driver mock'
Exemplo n.º 15
0
def test_create_local_driver_phantomjs(webdriver_mock, config):
    config.set('Driver', 'type', 'phantomjs')
    config.set('Driver', 'phantomjs_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)

    config_driver._create_local_driver()
    webdriver_mock.PhantomJS.assert_called_once_with(desired_capabilities=DesiredCapabilities.PHANTOMJS,
                                                     executable_path='/tmp/driver')
Exemplo n.º 16
0
def test_create_local_driver_phantomjs(webdriver_mock, config):
    config.set('Driver', 'type', 'phantomjs')
    config.set('Driver', 'phantomjs_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)

    config_driver._create_local_driver()
    webdriver_mock.PhantomJS.assert_called_once_with(desired_capabilities=DesiredCapabilities.PHANTOMJS,
                                                     executable_path='/tmp/driver')
Exemplo n.º 17
0
def test_add_firefox_arguments(config, utils):
    config.add_section('FirefoxArguments')
    config.set('FirefoxArguments', '-private', '')
    config_driver = ConfigDriver(config, utils)
    firefox_options = Options()

    config_driver._add_firefox_arguments(firefox_options)
    assert firefox_options.arguments == ['-private']
Exemplo n.º 18
0
def test_create_local_driver_opera(webdriver_mock, config):
    config.set('Driver', 'type', 'opera')
    config.set('Driver', 'opera_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)

    config_driver._create_local_driver()
    webdriver_mock.Opera.assert_called_once_with(desired_capabilities=DesiredCapabilities.OPERA,
                                                 executable_path='/tmp/driver')
Exemplo n.º 19
0
def test_create_local_driver_unknown_driver(config, utils):
    config.set('Driver', 'type', 'unknown')
    utils.get_driver_name.return_value = 'unknown'
    config_driver = ConfigDriver(config, utils)

    with pytest.raises(Exception) as excinfo:
        config_driver._create_local_driver()
    assert 'Unknown driver unknown' == str(excinfo.value)
Exemplo n.º 20
0
def test_create_local_driver_opera(webdriver_mock, config):
    config.set('Driver', 'type', 'opera')
    config.set('Driver', 'opera_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)

    config_driver._create_local_driver()
    webdriver_mock.Opera.assert_called_once_with(desired_capabilities=DesiredCapabilities.OPERA,
                                                 executable_path='/tmp/driver')
Exemplo n.º 21
0
    def test_create_local_driver_firefox(self, webdriver_mock):
        self.config.set('Driver', 'type', 'firefox')
        config_driver = ConfigDriver(self.config)
        config_driver._create_firefox_profile = lambda: 'firefox profile'

        config_driver._create_local_driver()
        webdriver_mock.Firefox.assert_called_once_with(capabilities=DesiredCapabilities.FIREFOX,
                                                       firefox_profile='firefox profile')
Exemplo n.º 22
0
def test_add_firefox_arguments(config):
    config.add_section('FirefoxArguments')
    config.set('FirefoxArguments', '-private', '')
    config_driver = ConfigDriver(config)
    firefox_options = Options()

    config_driver._add_firefox_arguments(firefox_options)
    assert firefox_options.arguments == ['-private']
Exemplo n.º 23
0
    def connect(self, maximize=True):
        """Set up the selenium driver and connect to the server

        :param maximize: True if the driver should be maximized
        :returns: selenium driver
        """
        if not self.config.get('Driver', 'type') or self.config.get(
                'Driver', 'type') in ['api', 'no_driver']:
            return None

        self.driver = ConfigDriver(self.config).create_driver()

        # Save session id and remote node to download video after the test execution
        self.session_id = self.driver.session_id
        self.remote_node = self.utils.get_remote_node()
        self.remote_node_video_enabled = self.utils.is_remote_video_enabled(
            self.remote_node)

        # Save app_strings in mobile tests
        if self.is_mobile_test(
        ) and not self.is_web_test() and self.config.getboolean_optional(
                'Driver', 'appium_app_strings'):
            self.app_strings = self.driver.app_strings()

        if self.is_maximizable():
            # Bounds and screen
            bounds_x, bounds_y = self.get_config_window_bounds()
            self.driver.set_window_position(bounds_x, bounds_y)
            self.logger.debug('Window bounds: %s x %s', bounds_x, bounds_y)

            # Maximize browser
            if maximize:
                # Set window size or maximize
                window_width = self.config.get_optional(
                    'Driver', 'window_width')
                window_height = self.config.get_optional(
                    'Driver', 'window_height')
                if window_width and window_height:
                    self.driver.set_window_size(window_width, window_height)
                else:
                    self.driver.maximize_window()

        # Log window size
        window_size = self.utils.get_window_size()
        self.logger.debug('Window size: %s x %s', window_size['width'],
                          window_size['height'])

        # Update baseline
        self.update_visual_baseline()

        # Discard previous logcat logs
        self.utils.discard_logcat_logs()

        # Set implicitly wait timeout
        self.utils.set_implicitly_wait()

        return self.driver
Exemplo n.º 24
0
def test_create_driver_local_not_configured(config):
    config.set('Driver', 'type', 'firefox')
    config_driver = ConfigDriver(config)
    config_driver._create_local_driver = lambda: 'local driver mock'
    config_driver._create_remote_driver = lambda: 'remote driver mock'

    driver = config_driver.create_driver()

    assert driver == 'local driver mock'
Exemplo n.º 25
0
    def test_create_driver_local_not_configured(self):
        self.config.set('Driver', 'type', 'firefox')
        config_driver = ConfigDriver(self.config)
        config_driver._create_local_driver = lambda: 'local driver mock'
        config_driver._create_remote_driver = lambda: 'remote driver mock'

        driver = config_driver.create_driver()

        assert_equal(driver, 'local driver mock')
Exemplo n.º 26
0
def test_create_local_driver_chrome(webdriver_mock, config):
    config.set('Driver', 'type', 'chrome')
    config.set('Driver', 'chrome_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)
    config_driver._create_chrome_options = lambda: 'chrome options'

    config_driver._create_local_driver()
    webdriver_mock.Chrome.assert_called_once_with('/tmp/driver', desired_capabilities=DesiredCapabilities.CHROME,
                                                  chrome_options='chrome options')
Exemplo n.º 27
0
def test_create_remote_driver_phantomjs(webdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'phantomjs')
    config_driver = ConfigDriver(config)

    config_driver._create_remote_driver()
    webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                  desired_capabilities=DesiredCapabilities.PHANTOMJS)
Exemplo n.º 28
0
def test_create_remote_driver_iexplore(webdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'iexplore')
    config_driver = ConfigDriver(config)

    config_driver._create_remote_driver()
    webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                  desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)
Exemplo n.º 29
0
def test_create_local_driver_chrome(webdriver_mock, config):
    config.set('Driver', 'type', 'chrome')
    config.set('Driver', 'chrome_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)
    config_driver._create_chrome_options = lambda: 'chrome options'

    config_driver._create_local_driver()
    webdriver_mock.Chrome.assert_called_once_with('/tmp/driver', desired_capabilities=DesiredCapabilities.CHROME,
                                                  chrome_options='chrome options')
Exemplo n.º 30
0
def test_create_driver_local_not_configured(config):
    config.set('Driver', 'type', 'firefox')
    config_driver = ConfigDriver(config)
    config_driver._create_local_driver = lambda: 'local driver mock'
    config_driver._create_remote_driver = lambda: 'remote driver mock'

    driver = config_driver.create_driver()

    assert driver == 'local driver mock'
Exemplo n.º 31
0
def test_create_local_driver_firefox(webdriver_mock, config):
    config.set('Driver', 'type', 'firefox')
    config_driver = ConfigDriver(config)
    config_driver._create_firefox_profile = lambda: 'firefox profile'

    config_driver._create_local_driver()
    webdriver_mock.Firefox.assert_called_once_with(capabilities=DesiredCapabilities.FIREFOX,
                                                   firefox_profile='firefox profile', executable_path=None,
                                                   firefox_options=None)
Exemplo n.º 32
0
def test_create_remote_driver_phantomjs(webdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'phantomjs')
    config_driver = ConfigDriver(config)

    config_driver._create_remote_driver()
    webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                  desired_capabilities=DesiredCapabilities.PHANTOMJS)
Exemplo n.º 33
0
def test_create_remote_driver_iexplore(webdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'iexplore')
    config_driver = ConfigDriver(config)

    config_driver._create_remote_driver()
    webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                  desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)
Exemplo n.º 34
0
    def test_create_remote_driver_edge(self, webdriver_mock):
        self.config.set('Server', 'host', '10.20.30.40')
        self.config.set('Server', 'port', '5555')
        self.config.set('Driver', 'type', 'edge')
        config_driver = ConfigDriver(self.config)

        config_driver._create_remote_driver()
        capabilities = DesiredCapabilities.EDGE
        webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                      desired_capabilities=capabilities)
Exemplo n.º 35
0
    def test_create_driver_remote(self):
        self.config.set('Server', 'enabled', 'true')
        self.config.set('Driver', 'type', 'firefox')
        config_driver = ConfigDriver(self.config)
        config_driver._create_local_driver = lambda: 'local driver mock'
        config_driver._create_remote_driver = lambda: 'remote driver mock'

        driver = config_driver.create_driver()

        assert_equal(driver, 'remote driver mock')
Exemplo n.º 36
0
def test_create_driver_local_not_configured(config, utils):
    config.set('Driver', 'type', 'firefox')
    utils.get_driver_name.return_value = 'firefox'
    config_driver = ConfigDriver(config, utils)
    config_driver._create_local_driver = lambda: 'local driver mock'
    config_driver._create_remote_driver = lambda: 'remote driver mock'

    driver = config_driver.create_driver()

    assert driver == 'local driver mock'
Exemplo n.º 37
0
def test_create_remote_driver_edge(webdriver_mock, config):
    config.set('Driver', 'type', 'edge')
    server_url = 'http://10.20.30.40:5555'
    utils = mock.MagicMock()
    utils.get_server_url.return_value = server_url
    config_driver = ConfigDriver(config, utils)

    config_driver._create_remote_driver()
    webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,
                                                  desired_capabilities=DesiredCapabilities.EDGE)
Exemplo n.º 38
0
def test_create_remote_driver_phantomjs(webdriver_mock, config, utils):
    config.set('Driver', 'type', 'phantomjs')
    server_url = 'http://10.20.30.40:5555'
    utils.get_server_url.return_value = server_url
    utils.get_driver_name.return_value = 'phantomjs'
    config_driver = ConfigDriver(config, utils)

    config_driver._create_remote_driver()
    webdriver_mock.Remote.assert_called_once_with(command_executor='%s/wd/hub' % server_url,
                                                  desired_capabilities=DesiredCapabilities.PHANTOMJS)
Exemplo n.º 39
0
def test_create_driver_remote(config):
    config.set('Server', 'enabled', 'true')
    config.set('Driver', 'type', 'firefox')
    config_driver = ConfigDriver(config)
    config_driver._create_local_driver = lambda: 'local driver mock'
    config_driver._create_remote_driver = lambda: 'remote driver mock'

    driver = config_driver.create_driver()

    assert driver == 'remote driver mock'
Exemplo n.º 40
0
def test_create_driver_remote(config):
    config.set('Server', 'enabled', 'true')
    config.set('Driver', 'type', 'firefox')
    config_driver = ConfigDriver(config)
    config_driver._create_local_driver = lambda: 'local driver mock'
    config_driver._create_remote_driver = lambda: 'remote driver mock'

    driver = config_driver.create_driver()

    assert driver == 'remote driver mock'
Exemplo n.º 41
0
def test_create_chrome_options_headless(webdriver_mock, config, utils):
    config.set('Driver', 'headless', 'true')
    config_driver = ConfigDriver(config, utils)

    config_driver._create_chrome_options()
    webdriver_mock.ChromeOptions.assert_called_once_with()
    if os.name == 'nt':
        webdriver_mock.ChromeOptions().add_argument.assert_has_calls([mock.call('--headless'),
                                                                      mock.call('--disable-gpu')])
    else:
        webdriver_mock.ChromeOptions().add_argument.assert_called_once_with('--headless')
Exemplo n.º 42
0
    def test_create_remote_driver_version(self, webdriver_mock):
        self.config.set('Server', 'host', '10.20.30.40')
        self.config.set('Server', 'port', '5555')
        self.config.set('Driver', 'type', 'iexplore-11')
        config_driver = ConfigDriver(self.config)

        config_driver._create_remote_driver()
        capabilities = DesiredCapabilities.INTERNETEXPLORER
        capabilities['version'] = '11'
        webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                      desired_capabilities=capabilities)
Exemplo n.º 43
0
def test_create_chrome_options_headless(webdriver_mock, config):
    config.set('Driver', 'headless', 'true')
    config_driver = ConfigDriver(config)

    config_driver._create_chrome_options()
    webdriver_mock.ChromeOptions.assert_called_once_with()
    if os.name == 'nt':
        webdriver_mock.ChromeOptions().add_argument.assert_has_calls([mock.call('--headless'),
                                                                      mock.call('--disable-gpu')])
    else:
        webdriver_mock.ChromeOptions().add_argument.assert_called_once_with('--headless')
Exemplo n.º 44
0
def test_create_remote_driver_version_platform(webdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'iexplore-11-on-WIN10')
    config_driver = ConfigDriver(config)

    config_driver._create_remote_driver()
    capabilities = DesiredCapabilities.INTERNETEXPLORER
    capabilities['version'] = '11'
    capabilities['platform'] = 'WIN10'
    webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                  desired_capabilities=capabilities)
Exemplo n.º 45
0
def test_create_remote_driver_opera(webdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'opera')
    config_driver = ConfigDriver(config)

    config_driver._create_remote_driver()
    capabilities = DesiredCapabilities.OPERA
    capabilities['opera.autostart'] = True
    capabilities['opera.arguments'] = '-fullscreen'
    webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                  desired_capabilities=capabilities)
Exemplo n.º 46
0
def test_create_remote_driver_opera(webdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'opera')
    config_driver = ConfigDriver(config)

    config_driver._create_remote_driver()
    capabilities = DesiredCapabilities.OPERA
    capabilities['opera.autostart'] = True
    capabilities['opera.arguments'] = '-fullscreen'
    webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                  desired_capabilities=capabilities)
Exemplo n.º 47
0
def test_create_local_driver_capabilities(webdriver_mock, config):
    config.set('Driver', 'type', 'firefox')
    config.add_section('Capabilities')
    config.set('Capabilities', 'version', '45')
    config_driver = ConfigDriver(config)
    config_driver._create_firefox_profile = lambda: 'firefox profile'

    config_driver._create_local_driver()
    capabilities = DesiredCapabilities.FIREFOX.copy()
    capabilities['version'] = '45'
    webdriver_mock.Firefox.assert_called_once_with(capabilities=capabilities,
                                                   firefox_profile='firefox profile', executable_path=None,
                                                   firefox_options=None)
Exemplo n.º 48
0
def test_create_remote_driver_capabilities(webdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'iexplore-11')
    config.add_section('Capabilities')
    config.set('Capabilities', 'version', '11')
    config_driver = ConfigDriver(config)

    config_driver._create_remote_driver()
    capabilities = DesiredCapabilities.INTERNETEXPLORER.copy()
    capabilities['version'] = '11'
    webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                  desired_capabilities=capabilities)
Exemplo n.º 49
0
def test_create_remote_driver_iphone(appiumdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'iphone')
    config.add_section('AppiumCapabilities')
    config.set('AppiumCapabilities', 'automationName', 'Appium')
    config.set('AppiumCapabilities', 'platformName', 'iOS')
    config_driver = ConfigDriver(config)

    config_driver._create_remote_driver()
    capabilities = {'automationName': 'Appium', 'platformName': 'iOS'}
    appiumdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                     desired_capabilities=capabilities)
Exemplo n.º 50
0
def test_create_local_driver_firefox(webdriver_mock, options, config):
    config.set('Driver', 'type', 'firefox')
    config.add_section('Capabilities')
    config.set('Capabilities', 'marionette', 'false')
    config_driver = ConfigDriver(config)
    config_driver._create_firefox_profile = lambda: 'firefox profile'
    DriverWrappersPool.output_directory = ''

    config_driver._create_local_driver()
    expected_capabilities = DesiredCapabilities.FIREFOX.copy()
    expected_capabilities['marionette'] = False
    webdriver_mock.Firefox.assert_called_once_with(capabilities=expected_capabilities,
                                                   firefox_profile='firefox profile', executable_path=None,
                                                   firefox_options=options(), log_path='geckodriver.log')
Exemplo n.º 51
0
def test_create_firefox_profile(webdriver_mock, config):
    config.add_section('Firefox')
    config.set('Firefox', 'profile', '/tmp')
    config.add_section('FirefoxPreferences')
    config.set('FirefoxPreferences', 'browser.download.folderList', '2')
    config.add_section('FirefoxExtensions')
    config.set('FirefoxExtensions', 'firebug', 'resources/firebug-3.0.0-beta.3.xpi')
    config_driver = ConfigDriver(config)

    config_driver._create_firefox_profile()
    webdriver_mock.FirefoxProfile.assert_called_once_with(profile_directory='/tmp')
    webdriver_mock.FirefoxProfile().set_preference.assert_called_once_with('browser.download.folderList', 2)
    webdriver_mock.FirefoxProfile().update_preferences.assert_called_once_with()
    webdriver_mock.FirefoxProfile().add_extension.assert_called_once_with('resources/firebug-3.0.0-beta.3.xpi')
Exemplo n.º 52
0
def test_create_local_driver_firefox_binary(webdriver_mock, config):
    config.set('Driver', 'type', 'firefox')
    config.add_section('Firefox')
    config.set('Firefox', 'binary', '/tmp/firefox')
    config_driver = ConfigDriver(config)
    config_driver._create_firefox_profile = lambda: 'firefox profile'

    config_driver._create_local_driver()

    # Check that firefox options contain the firefox binary
    args, kwargs = webdriver_mock.Firefox.call_args
    firefox_options = kwargs['firefox_options']
    assert isinstance(firefox_options, Options)
    assert firefox_options.binary == '/tmp/firefox'
Exemplo n.º 53
0
def test_create_local_driver_firefox_gecko(webdriver_mock, config):
    config.set('Driver', 'type', 'firefox')
    config.add_section('Capabilities')
    config.set('Capabilities', 'marionette', 'true')
    config.set('Driver', 'gecko_driver_path', '/tmp/driver')
    config_driver = ConfigDriver(config)
    config_driver._create_firefox_profile = lambda: 'firefox profile'

    config_driver._create_local_driver()
    expected_capabilities = DesiredCapabilities.FIREFOX.copy()
    expected_capabilities['marionette'] = True
    webdriver_mock.Firefox.assert_called_once_with(capabilities=expected_capabilities,
                                                   firefox_profile='firefox profile', executable_path='/tmp/driver',
                                                   firefox_options=None)
Exemplo n.º 54
0
def test_create_chrome_options(webdriver_mock, config):
    config.add_section('ChromePreferences')
    config.set('ChromePreferences', 'download.default_directory', '/tmp')
    config.add_section('ChromeMobileEmulation')
    config.set('ChromeMobileEmulation', 'deviceName', 'Google Nexus 5')
    config.add_section('ChromeArguments')
    config.set('ChromeArguments', 'lang', 'es')
    config_driver = ConfigDriver(config)

    config_driver._create_chrome_options()
    webdriver_mock.ChromeOptions.assert_called_once_with()
    webdriver_mock.ChromeOptions().add_experimental_option.assert_has_calls(
        [mock.call('prefs', {'download.default_directory': '/tmp'}),
         mock.call('mobileEmulation', {'deviceName': 'Google Nexus 5'})])
    webdriver_mock.ChromeOptions().add_argument.assert_called_once_with('lang=es')
Exemplo n.º 55
0
def test_create_remote_driver_chrome_old_selenium(webdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'chrome')
    config_driver = ConfigDriver(config)

    # Chrome options mock
    chrome_options = mock.MagicMock()
    chrome_options.to_capabilities.return_value = {'chromeOptions': 'chrome options'}
    config_driver._create_chrome_options = mock.MagicMock(return_value=chrome_options)

    config_driver._create_remote_driver()
    capabilities = DesiredCapabilities.CHROME.copy()
    capabilities['chromeOptions'] = 'chrome options'
    webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                  desired_capabilities=capabilities)
Exemplo n.º 56
0
def test_create_remote_driver_firefox(webdriver_mock, config):
    config.set('Server', 'host', '10.20.30.40')
    config.set('Server', 'port', '5555')
    config.set('Driver', 'type', 'firefox')
    config_driver = ConfigDriver(config)

    # Firefox profile mock
    class ProfileMock(object):
        encoded = 'encoded profile'

    config_driver._create_firefox_profile = mock.MagicMock(return_value=ProfileMock())

    config_driver._create_remote_driver()
    capabilities = DesiredCapabilities.FIREFOX.copy()
    capabilities['firefox_profile'] = 'encoded profile'
    webdriver_mock.Remote.assert_called_once_with(command_executor='http://10.20.30.40:5555/wd/hub',
                                                  desired_capabilities=capabilities)
Exemplo n.º 57
0
def test_create_local_driver_firefox_binary(webdriver_mock, config):
    config.set('Driver', 'type', 'firefox')
    config.add_section('Capabilities')
    config.set('Capabilities', 'marionette', 'false')
    config.add_section('Firefox')
    config.set('Firefox', 'binary', '/tmp/firefox')
    config_driver = ConfigDriver(config)
    config_driver._create_firefox_profile = lambda: 'firefox profile'
    DriverWrappersPool.output_directory = ''

    config_driver._create_local_driver()

    # Check that firefox options contain the firefox binary
    args, kwargs = webdriver_mock.Firefox.call_args
    firefox_options = kwargs['firefox_options']
    assert isinstance(firefox_options, Options)
    if isinstance(firefox_options.binary, str):
        assert firefox_options.binary == '/tmp/firefox'  # Selenium 2
    else:
        assert firefox_options.binary._start_cmd == '/tmp/firefox'  # Selenium 3
Exemplo n.º 58
0
    def connect(self, maximize=True):
        """Set up the selenium driver and connect to the server

        :param maximize: True if the driver should be maximized
        :returns: selenium driver
        """
        if not self.config.get('Driver', 'type') or self.config.get('Driver', 'type') in ['api', 'no_driver']:
            return None

        self.driver = ConfigDriver(self.config).create_driver()

        # Save session id and remote node to download video after the test execution
        self.session_id = self.driver.session_id
        self.remote_node = self.utils.get_remote_node()
        self.remote_node_video_enabled = self.utils.is_remote_video_enabled(self.remote_node)

        # Save app_strings in mobile tests
        if self.is_mobile_test() and not self.is_web_test() and self.config.getboolean_optional('Driver',
                                                                                                'appium_app_strings'):
            self.app_strings = self.driver.app_strings()

        if self.is_maximizable():
            # Bounds and screen
            bounds_x, bounds_y = self.get_config_window_bounds()
            self.driver.set_window_position(bounds_x, bounds_y)
            self.logger.debug('Window bounds: %s x %s', bounds_x, bounds_y)

            # Maximize browser
            if maximize:
                # Set window size or maximize
                window_width = self.config.get_optional('Driver', 'window_width')
                window_height = self.config.get_optional('Driver', 'window_height')
                if window_width and window_height:
                    self.driver.set_window_size(window_width, window_height)
                else:
                    self.driver.maximize_window()

        # Log window size
        window_size = self.utils.get_window_size()
        self.logger.debug('Window size: %s x %s', window_size['width'], window_size['height'])

        # Update baseline
        self.update_visual_baseline()

        # Discard previous logcat logs
        self.utils.discard_logcat_logs()

        # Set implicitly wait timeout
        self.utils.set_implicitly_wait()

        return self.driver
Exemplo n.º 59
0
    def connect(self, maximize=True):
        """Set up the selenium driver and connect to the server

        :param maximize: True if the driver should be maximized
        :returns: selenium driver
        """
        if not self.config.get('Driver', 'type'):
            return None

        self.driver = ConfigDriver(self.config).create_driver()

        # Save session id and remote node to download video after the test execution
        self.session_id = self.driver.session_id
        self.remote_node = self.utils.get_remote_node()
        self.remote_node_video_enabled = self.utils.is_remote_video_enabled(self.remote_node)

        # Save app_strings in mobile tests
        if self.is_mobile_test() and not self.is_web_test() and self.config.getboolean_optional('Driver',
                                                                                                'appium_app_strings'):
            self.app_strings = self.driver.app_strings()

        # Maximize browser
        if maximize and self.is_maximizable():
            # Set window size or maximize
            window_width = self.config.get_optional('Driver', 'window_width')
            window_height = self.config.get_optional('Driver', 'window_height')
            if window_width and window_height:
                self.driver.set_window_size(window_width, window_height)
            else:
                self.driver.maximize_window()

        # Log window size
        window_size = self.utils.get_window_size()
        self.logger.debug('Window size: {} x {}'.format(window_size['width'], window_size['height']))

        # Update baseline
        self.update_visual_baseline()

        return self.driver
Exemplo n.º 60
0
def test_convert_property_type_str(config):
    config_driver = ConfigDriver(config)
    value = 'string'
    assert config_driver._convert_property_type(value) == value