コード例 #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))
コード例 #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)
コード例 #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')
コード例 #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)
コード例 #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)
コード例 #6
0
ファイル: test_config_driver.py プロジェクト: rrosajp/toolium
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)
コード例 #7
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #8
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #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)
コード例 #10
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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'
コード例 #11
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #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'
コード例 #13
0
ファイル: test_config_driver.py プロジェクト: rrosajp/toolium
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)
コード例 #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'
コード例 #15
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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')
コード例 #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')
コード例 #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']
コード例 #18
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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')
コード例 #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)
コード例 #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')
コード例 #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')
コード例 #22
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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']
コード例 #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
コード例 #24
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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'
コード例 #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')
コード例 #26
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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')
コード例 #27
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #28
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #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')
コード例 #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'
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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')
コード例 #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'
コード例 #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)
コード例 #38
0
ファイル: test_config_driver.py プロジェクト: rrosajp/toolium
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)
コード例 #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'
コード例 #40
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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'
コード例 #41
0
ファイル: test_config_driver.py プロジェクト: rrosajp/toolium
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')
コード例 #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)
コード例 #43
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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')
コード例 #44
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #45
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #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)
コード例 #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)
コード例 #48
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #49
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #50
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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')
コード例 #51
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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')
コード例 #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'
コード例 #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)
コード例 #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')
コード例 #55
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #56
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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)
コード例 #57
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
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
コード例 #58
0
ファイル: driver_wrapper.py プロジェクト: jframos/toolium
    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
コード例 #59
0
ファイル: driver_wrapper.py プロジェクト: rgonalo/toolium
    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
コード例 #60
0
ファイル: test_config_driver.py プロジェクト: jframos/toolium
def test_convert_property_type_str(config):
    config_driver = ConfigDriver(config)
    value = 'string'
    assert config_driver._convert_property_type(value) == value