コード例 #1
0
 def test_bad_browser_name(self):
     bm = BrowserManagementKeywords()
     try:
         bm._make_browser("fireox")
         self.fail("Exception not raised")
     except ValueError as e:
         self.assertEquals(str(e), "fireox is not a supported browser.")
コード例 #2
0
 def test_parse_complex_capabilities_string(self):
     bm = BrowserManagementKeywords()
     expected_caps = "proxyType:manual,httpProxy:IP:port"
     capabilities = bm._parse_capabilities_string(expected_caps)
     self.assertTrue("manual", capabilities["proxyType"])
     self.assertTrue("IP:port", capabilities["httpProxy"])
     self.assertTrue(2, len(capabilities))
コード例 #3
0
 def test_parse_capabilities_string(self):
     bm = BrowserManagementKeywords()
     expected_caps = "key1:val1,key2:val2"
     capabilities = bm._parse_capabilities_string(expected_caps)
     self.assertTrue("val1", capabilities["key1"])
     self.assertTrue("val2", capabilities["key2"])
     self.assertTrue(2, len(capabilities))
コード例 #4
0
    def __init__(self):
        BrowserManagementKeywords.__init__(self)

        def mock_logging_method(self, *args, **kwargs):
            pass

        for name in ['_info', '_debug', '_warn', '_log', '_html']:
            setattr(self, name, mock_logging_method)
コード例 #5
0
    def verify_browser(self , webdriver_type , browser_name, **kw):
        #todo try lambda *x: was_called = true
        bm = BrowserManagementKeywords()
        old_init = webdriver_type.__init__
        webdriver_type.__init__ = self.mock_init

        try:
            self.was_called = False
            bm._make_browser(browser_name, **kw)
        except AttributeError:
            pass #kinda dangerous but I'm too lazy to mock out all the set_timeout calls
        finally:
            webdriver_type.__init__ = old_init
            self.assertTrue(self.was_called)
コード例 #6
0
 def test_create_webdriver(self):
     ctx = mock()
     bm = BrowserManagementKeywords(ctx)
     FakeWebDriver = mock()
     driver = mock()
     when(FakeWebDriver).__call__(some_arg=1).thenReturn(driver)
     when(FakeWebDriver).__call__(some_arg=2).thenReturn(driver)
     when(ctx).register_browser(driver, 'fake1').thenReturn(0)
     webdriver.FakeWebDriver = FakeWebDriver
     try:
         index = bm.create_webdriver('FakeWebDriver', 'fake1', some_arg=1)
         verify(ctx).register_browser(driver, 'fake1')
         self.assertEqual(index, 0)
         my_kwargs = {'some_arg': 2}
         bm.create_webdriver('FakeWebDriver', 'fake2', kwargs=my_kwargs)
         verify(ctx).register_browser(driver, 'fake2')
     finally:
         del webdriver.FakeWebDriver
     unstub()
コード例 #7
0
 def test_set_selenium_timeout_only_affects_open_browsers(self):
     bm = BrowserManagementKeywords()
     first_browser, second_browser = mock(), mock()
     bm._cache.register(first_browser)
     bm._cache.close()
     verify(first_browser).quit()
     bm._cache.register(second_browser)
     bm.set_selenium_timeout("10 seconds")
     verify(second_browser).set_script_timeout(10.0)
     bm._cache.close_all()
     verify(second_browser).quit()
     bm.set_selenium_timeout("20 seconds")
     verifyNoMoreInteractions(first_browser)
     verifyNoMoreInteractions(second_browser)
コード例 #8
0
 def test_set_selenium_timeout_only_affects_open_browsers(self):
     ctx = mock()
     ctx._timeout_in_secs = 5.0
     _browsers = mock()
     ctx._browsers = _browsers
     first_browser, second_browser = mock(), mock()
     when(_browsers).get_open_browsers().thenReturn(
         [first_browser, second_browser]
     )
     bm = BrowserManagementKeywords(ctx)
     bm.set_selenium_timeout("10 seconds")
     verify(first_browser).set_script_timeout(10.0)
     verify(second_browser).set_script_timeout(10.0)
     when(_browsers).get_open_browsers().thenReturn(
         []
     )
     bm.set_selenium_timeout("20 seconds")
     verifyNoMoreInteractions(first_browser)
     verifyNoMoreInteractions(second_browser)
     unstub()