def open_browser(
     self,
     url,
     browser="firefox",
     alias=None,
     remote_url=False,
     desired_capabilities=None,
     ff_profile_dir=None,
     options=None,
     service_log_path=None,
     extra_dictionary=None,
     executable_path=None,
 ):
     self._new_creator.extra_dictionary = extra_dictionary
     browser_manager = BrowserManagementKeywords(self.ctx)
     browser_manager._make_driver = self._make_driver
     browser_manager.open_browser(
         url,
         browser=browser,
         alias=alias,
         remote_url=remote_url,
         desired_capabilities=desired_capabilities,
         ff_profile_dir=ff_profile_dir,
         options=options,
         service_log_path=service_log_path,
         executable_path=None,
     )
class KeywordArgumentsElementTest(unittest.TestCase):

    def setUp(self):
        ctx = mock()
        ctx.event_firing_webdriver = None
        ctx._browser = mock()
        ctx._drivers = mock()
        self.brorser = BrowserManagementKeywords(ctx)

    def tearDown(self):
        unstub()

    def test_open_browser(self):
        url = 'https://github.com/robotframework'
        remote_url = '"http://localhost:4444/wd/hub"'
        browser = mock()
        when(self.brorser)._make_driver('firefox', None,
                                        None, False).thenReturn(browser)
        alias = self.brorser.open_browser(url)
        self.assertEqual(alias, None)

        when(self.brorser)._make_driver('firefox', None,
                                        None, remote_url).thenReturn(browser)
        alias = self.brorser.open_browser(url, alias='None',
                                          remote_url=remote_url)
        self.assertEqual(alias, None)
Exemple #3
0
class KeywordArgumentsElementTest(unittest.TestCase):
    def setUp(self):
        ctx = mock()
        ctx.event_firing_webdriver = None
        ctx._browser = mock()
        ctx._drivers = mock()
        self.brorser = BrowserManagementKeywords(ctx)

    def tearDown(self):
        unstub()

    def test_open_browser(self):
        url = 'https://github.com/robotframework'
        remote_url = '"http://localhost:4444/wd/hub"'
        browser = mock()
        when(self.brorser)._make_driver('firefox', None, None,
                                        False).thenReturn(browser)
        alias = self.brorser.open_browser(url)
        self.assertEqual(alias, None)

        when(self.brorser)._make_driver('firefox', None, None,
                                        remote_url).thenReturn(browser)
        alias = self.brorser.open_browser(url,
                                          alias='None',
                                          remote_url=remote_url)
        self.assertEqual(alias, None)
 def test_create_webdriver_speed(self):
     ctx = mock()
     ctx.speed = 0.0
     browser = mock()
     when(webdriver).Chrome().thenReturn(browser)
     bm = BrowserManagementKeywords(ctx)
     bm.open_browser('http://robotframework.org/', 'chrome')
     verify(browser, times=0).__call__('_speed')
     unstub()
 def test_open_browser_speed(self):
     ctx = mock()
     ctx.speed = 5.0
     browser = mock()
     when(webdriver).Chrome().thenReturn(browser)
     bm = BrowserManagementKeywords(ctx)
     bm.open_browser('http://robotframework.org/', 'chrome')
     self.assertEqual(browser._speed, 5.0)
     unstub()
 def test_create_webdriver_speed(self):
     ctx = mock()
     ctx.speed = 0.0
     browser = mock()
     when(webdriver).Chrome().thenReturn(browser)
     bm = BrowserManagementKeywords(ctx)
     bm.open_browser('http://robotframework.org/', 'chrome')
     verify(browser, times=0).__call__('_speed')
     unstub()
 def test_open_browser_speed(self):
     ctx = mock()
     ctx.speed = 5.0
     browser = mock()
     when(webdriver).Chrome().thenReturn(browser)
     bm = BrowserManagementKeywords(ctx)
     bm.open_browser('http://robotframework.org/', 'chrome')
     self.assertEqual(browser._speed, 5.0)
     unstub()
Exemple #8
0
 def test_open_browser_speed(self):
     ctx = mock()
     ctx._drivers = mock()
     ctx.event_firing_webdriver = None
     ctx.speed = 5.0
     browser = mock()
     when(webdriver).Chrome(options=None,
                            service_log_path=None).thenReturn(browser)
     bm = BrowserManagementKeywords(ctx)
     bm.open_browser('http://robotframework.org/', 'chrome')
     self.assertEqual(browser._speed, 5.0)
     unstub()
Exemple #9
0
 def test_create_webdriver_speed(self):
     ctx = mock()
     ctx._drivers = mock()
     ctx.event_firing_webdriver = None
     ctx.speed = 0.0
     browser = mock()
     when(webdriver).Chrome(options=None,
                            service_log_path=None).thenReturn(browser)
     bm = BrowserManagementKeywords(ctx)
     bm.open_browser('http://robotframework.org/', 'chrome')
     verify(browser, times=0).__call__('_speed')
     unstub()
def test_open_browser_speed():
    ctx = mock()
    ctx._drivers = mock()
    ctx.event_firing_webdriver = None
    ctx.speed = 5.0
    browser = mock()
    executable_path = "chromedriver"
    when(webdriver).Chrome(options=None,
                           service_log_path=None,
                           executable_path=executable_path).thenReturn(browser)
    bm = BrowserManagementKeywords(ctx)
    when(bm._webdriver_creator)._get_executable_path(ANY).thenReturn(
        executable_path)
    bm.open_browser("http://robotframework.org/", "chrome")
    assert browser._speed == 5.0
def test_create_webdriver_speed():
    ctx = mock()
    ctx._drivers = mock()
    ctx.event_firing_webdriver = None
    ctx.speed = 0.0
    browser = mock()
    executable_path = 'chromedriver'
    when(webdriver).Chrome(options=None,
                           service_log_path=None,
                           executable_path=executable_path).thenReturn(browser)
    bm = BrowserManagementKeywords(ctx)
    when(bm._webdriver_creator)._get_executable_path(ANY).thenReturn(
        executable_path)
    bm.open_browser('http://robotframework.org/', 'chrome')
    verify(browser, times=0).__call__('_speed')
 def test_create_webdriver_speed(self):
     ctx = mock()
     ctx.speed = 0.0
     browser = mock()
     caps = webdriver.DesiredCapabilities.CHROME
     if SELENIUM_VERSION.major >= '3' and SELENIUM_VERSION.minor >= '8':
         when(webdriver).Chrome(desired_capabilities=caps,
                                options=None).thenReturn(browser)
     else:
         when(webdriver).Chrome(
             desired_capabilities=caps).thenReturn(browser)
     bm = BrowserManagementKeywords(ctx)
     bm.open_browser('http://robotframework.org/', 'chrome')
     verify(browser, times=0).__call__('_speed')
     unstub()
 def test_open_browser_speed(self):
     ctx = mock()
     ctx.speed = 5.0
     browser = mock()
     caps = webdriver.DesiredCapabilities.CHROME
     if SELENIUM_VERSION.major >= '3' and SELENIUM_VERSION.minor >= '8':
         when(webdriver).Chrome(desired_capabilities=caps,
                                options=None).thenReturn(browser)
     else:
         when(webdriver).Chrome(
             desired_capabilities=caps).thenReturn(browser)
     bm = BrowserManagementKeywords(ctx)
     bm.open_browser('http://robotframework.org/', 'chrome')
     self.assertEqual(browser._speed, 5.0)
     unstub()
Exemple #14
0
class KeywordArgumentsElementTest(unittest.TestCase):
    def setUp(self):
        ctx = mock()
        ctx.event_firing_webdriver = None
        ctx._browser = mock()
        ctx._drivers = mock()
        self.ctx = ctx
        self.brorser = BrowserManagementKeywords(ctx)

    def tearDown(self):
        unstub()

    def test_open_browser(self):
        url = "https://github.com/robotframework"
        remote_url = '"http://localhost:4444/wd/hub"'
        browser = mock()
        when(self.brorser)._make_driver(
            "firefox", None, None, False, None, None, None
        ).thenReturn(browser)
        alias = self.brorser.open_browser(url)
        self.assertEqual(alias, None)

        when(self.brorser)._make_driver(
            "firefox", None, None, remote_url, None, None, None
        ).thenReturn(browser)
        alias = self.brorser.open_browser(url, alias="None", remote_url=remote_url)
        self.assertEqual(alias, None)

    def test_same_alias(self):
        url = "https://github.com/robotframework"
        alias = "tidii"
        driver = mock()
        driver.session_id = "foobar"
        self.ctx.driver = driver
        when(self.ctx._drivers).get_index(alias).thenReturn(1)
        when(self.ctx._drivers).switch(1).thenReturn(driver)
        self.brorser.open_browser(url=url, alias=alias)
        verify(driver, times=1).get(url)

    def test_open_browser_no_get(self):
        browser = mock()
        when(self.brorser)._make_driver(
            "firefox", None, None, False, None, None, None
        ).thenReturn(browser)
        self.brorser.open_browser()
        verify(browser, times=0).get(ANY)

    def test_same_alias_and_not_get(self):
        alias = "tidii"
        driver = mock()
        driver.session_id = "foobar"
        self.ctx.driver = driver
        when(self.ctx._drivers).get_index(alias).thenReturn(1)
        when(self.ctx._drivers).switch(1).thenReturn(driver)
        self.brorser.open_browser(alias=alias)
        verify(driver, times=0).get(ANY)
 def open_browser(self, host):
     logger.info('This is keyword from KeywordClass')
     url = 'http://{}:7272/'.format(host)
     browser_management = BrowserManagementKeywords(self.ctx)
     browser_management.open_browser(url, 'chrome')
 def open_browser(self, host):
     url = 'http://{}.com/'.format(host)
     browser_management = BrowserManagementKeywords(self.ctx)
     browser_management.open_browser(url, 'chrome')
 def open_browser(self, host):
     logger.info('This is keyword from KeywordClass')
     url = 'http://{}.com/'.format(host)
     browser_management = BrowserManagementKeywords(self.ctx)
     browser_management.open_browser(url, 'chrome')
Exemple #18
0
 def open_browser(self, host):
     url = 'http://{}:7272/'.format(host)
     browser_management = BrowserManagementKeywords(self)
     browser_management.open_browser(url, 'chrome')
 def open_browser(self, host):
     url = f'http://{host}.com/'
     browser_management = BrowserManagementKeywords(self)
     browser_management.open_browser(url, 'chrome')
Exemple #20
0
 def open_browser(self, host):
     url = f"http://{host}.com/"
     browser_management = BrowserManagementKeywords(self)
     browser_management.open_browser(url, "chrome")