Permalink
Browse files

move some testing to unit tests

acceptance test opens browser passed to run_tests.py
  • Loading branch information...
1 parent 33e0517 commit 07005979668c098762bda0f9d6ad017da0153af5 @ombre42 ombre42 committed Nov 8, 2013
Showing with 35 additions and 25 deletions.
  1. +7 −25 test/acceptance/create_webdriver.txt
  2. +28 −0 test/unit/keywords/test_browsermanagement.py
@@ -1,32 +1,14 @@
*Setting*
-Suite Teardown Close All Browsers
Resource resource.txt
Library Collections
*Test Cases*
Create Webdriver Creates Functioning WebDriver
- [Documentation] LOG 1:1 INFO Creating an instance of the Firefox WebDriver LOG 1:3 DEBUG REGEXP: Created Firefox WebDriver instance with session id (\\w|-)+
- ${index}= Create Webdriver Firefox createwebdriver
+ [Documentation] LOG 2:1 INFO REGEXP: Creating an instance of the \\w+ WebDriver LOG 2:3 DEBUG REGEXP: Created \\w+ WebDriver instance with session id (\\w|-)+
+ [Setup] Set Driver Name
+ Create Webdriver ${DRIVER NAME} createwebdriver
Go To ${FRONT PAGE}
Page Should Contain needle
- ${index as int}= Convert To Integer ${index}
- Should Be Equal ${index} ${index as int}
- Switch Browser createwebdriver
- [Teardown] Close Browser
-
-Create Webdriver With Keyword Argument
- ${proxy}= Create Bad Proxy
- Create Webdriver Firefox proxy=${proxy}
- Go To ${FRONT PAGE}
- Page Should Contain The proxy server is refusing connections
- [Teardown] Close Browser
-
-Create Webdriver With Keyword Argument Dictionary
- ${proxy}= Create Bad Proxy
- ${kwargs}= Create Dictionary proxy ${proxy}
- Create Webdriver Firefox kwargs=${kwargs}
- Go To ${FRONT PAGE}
- Page Should Contain The proxy server is refusing connections
[Teardown] Close Browser
Create Webdriver With Bad Driver Name
@@ -40,7 +22,7 @@ Create Webdriver With Bad Keyword Argument Dictionary
Run Keyword And Expect Error kwargs must be a dictionary. Create Webdriver Firefox kwargs={'spam': 'eggs'}
*Keywords*
-Create Bad Proxy
- ${proxy}= Evaluate sys.modules['selenium.webdriver'].Proxy() sys, selenium.webdriver
- ${proxy.http_proxy}= Set Variable localhost:7777
- [Return] ${proxy}
+Set Driver Name
+ ${drivers}= Create Dictionary firefox Firefox ie Ie internetexplorer Ie googlechrome Chrome gc Chrome opera Opera phantomjs PhantomJS safari Safari
+ ${name}= Get From Dictionary ${drivers} ${browser.lower().replace(' ', '')}
+ Set Test Variable ${DRIVER NAME} ${name}
@@ -85,6 +85,27 @@ def test_bad_browser_name(self):
except ValueError, e:
self.assertEquals("fireox is not a supported browser.", e.message)
+ def test_create_webdriver(self):
+ bm = _BrowserManagementWithLoggingStubs()
+ capt_data = {}
+ class FakeWebDriver(mock):
+ def __init__(self, some_arg=None):
+ mock.__init__(self)
+ capt_data['some_arg'] = some_arg
+ capt_data['webdriver'] = self
+ webdriver.FakeWebDriver = FakeWebDriver
+ try:
+ index = bm.create_webdriver('FakeWebDriver', some_arg=1)
+ self.assertEquals(capt_data['some_arg'], 1)
+ self.assertEquals(capt_data['webdriver'], bm._current_browser())
+ self.assertEquals(capt_data['webdriver'], bm._cache.get_connection(index))
+ capt_data.clear()
+ my_kwargs = {'some_arg':2}
+ bm.create_webdriver('FakeWebDriver', kwargs=my_kwargs)
+ self.assertEquals(capt_data['some_arg'], 2)
+ finally:
+ del webdriver.FakeWebDriver
+
def verify_browser(self , webdriver_type , browser_name, **kw):
#todo try lambda *x: was_called = true
bm = _BrowserManagementKeywords()
@@ -104,4 +125,11 @@ def mock_init(self, *args, **kw):
self.was_called = True
+class _BrowserManagementWithLoggingStubs(_BrowserManagementKeywords):
+ 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)

0 comments on commit 0700597

Please sign in to comment.