From f9ad6e9d1c31913e65bd12f699d076a6b20d6af1 Mon Sep 17 00:00:00 2001 From: Kevin Ormbrek Date: Tue, 22 Oct 2013 20:35:27 -0500 Subject: [PATCH 1/6] Implement 'Create Webdriver' keyword --- .../keywords/_browsermanagement.py | 43 +++++++++++++++++++ test/acceptance/create_webdriver.txt | 29 +++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 test/acceptance/create_webdriver.txt diff --git a/src/Selenium2Library/keywords/_browsermanagement.py b/src/Selenium2Library/keywords/_browsermanagement.py index bc08e26de..3651bb767 100644 --- a/src/Selenium2Library/keywords/_browsermanagement.py +++ b/src/Selenium2Library/keywords/_browsermanagement.py @@ -114,6 +114,49 @@ def open_browser(self, url, browser='firefox', alias=None,remote_url=False, % browser.session_id) return self._cache.register(browser, alias) + def create_webdriver(self, driver_name, alias=None, *name_value_pairs): + """Creates an instance of a WebDriver. + + Like `Open Browser`, but allows you to pass arguments to a WebDriver's + __init__. _Open Browser_ is preferred over _Create Webdriver_ when + feasible. + + `driver_name` must be the exact name of a WebDriver in + _selenium.webdriver_ to use. WebDriver names include: Firefox, Chrome, + Ie, Opera, Safari, PhantomJS, and Remote. + + `name_value_pairs` should be a list of parameter names and values. + Parameter names must be exact. See the + [http://selenium.googlecode.com/git/docs/api/py/api.html|Selenium API Documentation] + for information about parameter names and appropriate values. + + Examples: + | # use a proxy for PhantomJS | | | | | | + | ${service args}= | Create List | --proxy=192.168.132.104:8888 | | | | + | Create Webdriver | PhantomJS | phantomjs | service_args | ${service args} | | + | # use proxy for Firefox | | | | | | + | ${proxy}= | Evaluate | sys.modules['selenium.webdriver'].Proxy() | sys, selenium.webdriver | | | + | ${proxy.http_proxy}= | Set Variable | localhost:8888 | | | | + | Create Webdriver | Firefox | firefox | proxy | ${proxy} | | + | # debug IE driver | | | | | | + | ${driver args}= | Create List | log_level | DEBUG | log_file | %{HOMEPATH}${/}ie.log | + | Create Webdriver | Ie | ie | @{driver args} | | | + """ + if len(name_value_pairs) % 2 != 0: + raise RuntimeError("There should be an even number of parameter name-value pairs.") + kwargs = {} + for i in range(0, len(name_value_pairs), 2): + kwargs[name_value_pairs[i].strip()] = name_value_pairs[i+1] + driver_name = driver_name.strip() + try: + creation_func = getattr(webdriver, driver_name) + except AttributeError: + raise RuntimeError("'%s' is not a valid WebDriver name" % driver_name) + self._info("Creating an instance of the %s WebDriver" % driver_name) + driver = creation_func(**kwargs) + self._debug("Created %s WebDriver instance with session id %s" % (driver_name, driver.session_id)) + return self._cache.register(driver, alias) + def switch_browser(self, index_or_alias): """Switches between active browsers using index or alias. diff --git a/test/acceptance/create_webdriver.txt b/test/acceptance/create_webdriver.txt new file mode 100644 index 000000000..f7a57c766 --- /dev/null +++ b/test/acceptance/create_webdriver.txt @@ -0,0 +1,29 @@ +*Setting* +Suite Teardown Close All Browsers +Resource resource.txt + + +*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 firefox + Go To ${FRONT PAGE} + Page Should Contain needle + ${index as int}= Convert To Integer ${index} + Should Be Equal ${index} ${index as int} + [Teardown] Close Browser + +Create Webdriver With Missing Value + Run Keyword And Expect Error There should be an even number of parameter name-value pairs. Create Webdriver Firefox firefox proxy + +Create Webdriver With WebDriver Argument + ${proxy}= Evaluate sys.modules['selenium.webdriver'].Proxy() sys, selenium.webdriver + ${proxy.http_proxy}= Set Variable localhost:7777 + Create Webdriver Firefox firefox proxy ${proxy} + Go To ${FRONT PAGE} + Page Should Contain The proxy server is refusing connections + [Teardown] Close Browser + +Create Webdriver With Bad Driver Name + Run Keyword And Expect Error 'Fireox' is not a valid WebDriver name Create Webdriver Fireox From 8e180266537b943304e603d216cc501ac1cd988a Mon Sep 17 00:00:00 2001 From: Kevin Ormbrek Date: Sat, 2 Nov 2013 17:24:30 -0500 Subject: [PATCH 2/6] Support and prefer keyword arguments Documentation also improved and added some missing test coverage --- .../keywords/_browsermanagement.py | 49 ++++++++++++------- test/acceptance/create_webdriver.txt | 18 ++++++- 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/Selenium2Library/keywords/_browsermanagement.py b/src/Selenium2Library/keywords/_browsermanagement.py index 3651bb767..cabcb815f 100644 --- a/src/Selenium2Library/keywords/_browsermanagement.py +++ b/src/Selenium2Library/keywords/_browsermanagement.py @@ -114,46 +114,57 @@ def open_browser(self, url, browser='firefox', alias=None,remote_url=False, % browser.session_id) return self._cache.register(browser, alias) - def create_webdriver(self, driver_name, alias=None, *name_value_pairs): + def create_webdriver(self, driver_name, alias=None, *name_value_pairs, **init_kwargs): """Creates an instance of a WebDriver. - Like `Open Browser`, but allows you to pass arguments to a WebDriver's + Like `Open Browser`, but allows passing arguments to a WebDriver's __init__. _Open Browser_ is preferred over _Create Webdriver_ when feasible. + Returns the index of this browser instance which can be used later to + switch back to it. Index starts from 1 and is reset back to it when + `Close All Browsers` keyword is used. See `Switch Browser` for + example. + `driver_name` must be the exact name of a WebDriver in _selenium.webdriver_ to use. WebDriver names include: Firefox, Chrome, Ie, Opera, Safari, PhantomJS, and Remote. - `name_value_pairs` should be a list of parameter names and values. - Parameter names must be exact. See the + Use keyword arguments to specify the arguments you want to pass to + the WebDriver's __init__. The values of the arguments are not + processed in any way before being passed on. For Robot Framework + < 2.8, which does not support keyword arguments, use a list of + argument names and value to specify the arguments instead . See the [http://selenium.googlecode.com/git/docs/api/py/api.html|Selenium API Documentation] - for information about parameter names and appropriate values. + for information about argument names and appropriate argument values. Examples: - | # use a proxy for PhantomJS | | | | | | - | ${service args}= | Create List | --proxy=192.168.132.104:8888 | | | | - | Create Webdriver | PhantomJS | phantomjs | service_args | ${service args} | | - | # use proxy for Firefox | | | | | | - | ${proxy}= | Evaluate | sys.modules['selenium.webdriver'].Proxy() | sys, selenium.webdriver | | | - | ${proxy.http_proxy}= | Set Variable | localhost:8888 | | | | - | Create Webdriver | Firefox | firefox | proxy | ${proxy} | | - | # debug IE driver | | | | | | - | ${driver args}= | Create List | log_level | DEBUG | log_file | %{HOMEPATH}${/}ie.log | - | Create Webdriver | Ie | ie | @{driver args} | | | + | # use proxy for Firefox | | | | + | ${proxy}= | Evaluate | sys.modules['selenium.webdriver'].Proxy() | sys, selenium.webdriver | + | ${proxy.http_proxy}= | Set Variable | localhost:8888 | | + | Create Webdriver | Firefox | proxy=${proxy} | | + | # debug IE driver | | | | + | Create Webdriver | Ie | log_level=DEBUG | log_file=%{HOMEPATH}${/}ie.log | + + Example for Robot Framework < 2.8: + | # use a proxy for PhantomJS | | | | | + | ${service args}= | Create List | --proxy=192.168.132.104:8888 | | | + | Create Webdriver | PhantomJS | phantomjs | service_args | ${service args} | """ if len(name_value_pairs) % 2 != 0: - raise RuntimeError("There should be an even number of parameter name-value pairs.") - kwargs = {} + raise RuntimeError("There should be an even number of argument name-value pairs.") for i in range(0, len(name_value_pairs), 2): - kwargs[name_value_pairs[i].strip()] = name_value_pairs[i+1] + arg_name = name_value_pairs[i].strip() + if arg_name in init_kwargs: + raise RuntimeError("Got multiple values for argument '%s'." % arg_name) + init_kwargs[arg_name] = name_value_pairs[i+1] driver_name = driver_name.strip() try: creation_func = getattr(webdriver, driver_name) except AttributeError: raise RuntimeError("'%s' is not a valid WebDriver name" % driver_name) self._info("Creating an instance of the %s WebDriver" % driver_name) - driver = creation_func(**kwargs) + driver = creation_func(**init_kwargs) self._debug("Created %s WebDriver instance with session id %s" % (driver_name, driver.session_id)) return self._cache.register(driver, alias) diff --git a/test/acceptance/create_webdriver.txt b/test/acceptance/create_webdriver.txt index f7a57c766..eb274955d 100644 --- a/test/acceptance/create_webdriver.txt +++ b/test/acceptance/create_webdriver.txt @@ -12,12 +12,21 @@ Create Webdriver Creates Functioning WebDriver Page Should Contain needle ${index as int}= Convert To Integer ${index} Should Be Equal ${index} ${index as int} + Switch Browser firefox [Teardown] Close Browser Create Webdriver With Missing Value - Run Keyword And Expect Error There should be an even number of parameter name-value pairs. Create Webdriver Firefox firefox proxy + Run Keyword And Expect Error There should be an even number of argument name-value pairs. Create Webdriver Firefox firefox proxy -Create Webdriver With WebDriver Argument +Create Webdriver With Keyword Argument + ${proxy}= Evaluate sys.modules['selenium.webdriver'].Proxy() sys, selenium.webdriver + ${proxy.http_proxy}= Set Variable localhost:7777 + Create Webdriver Firefox proxy=${proxy} + Go To ${FRONT PAGE} + Page Should Contain The proxy server is refusing connections + [Teardown] Close Browser + +Create Webdriver With List Argument ${proxy}= Evaluate sys.modules['selenium.webdriver'].Proxy() sys, selenium.webdriver ${proxy.http_proxy}= Set Variable localhost:7777 Create Webdriver Firefox firefox proxy ${proxy} @@ -27,3 +36,8 @@ Create Webdriver With WebDriver Argument Create Webdriver With Bad Driver Name Run Keyword And Expect Error 'Fireox' is not a valid WebDriver name Create Webdriver Fireox + +Create Webdriver With Duplicate Arguments + Run Keyword And Expect Error Got multiple values for argument 'arg'. Create Webdriver Firefox firefox arg 1 arg=2 + Run Keyword And Expect Error Got multiple values for argument 'arg'. Create Webdriver Firefox firefox arg 1 arg 2 + \ No newline at end of file From 33e0517be7ef1b554cc09524d3b4b4a4dc87e416 Mon Sep 17 00:00:00 2001 From: Kevin Ormbrek Date: Tue, 5 Nov 2013 21:12:28 -0600 Subject: [PATCH 3/6] use dict argument for backwards compatibility --- .../keywords/_browsermanagement.py | 34 +++++++++--------- test/acceptance/create_webdriver.txt | 35 ++++++++++--------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/Selenium2Library/keywords/_browsermanagement.py b/src/Selenium2Library/keywords/_browsermanagement.py index cabcb815f..489c9db3f 100644 --- a/src/Selenium2Library/keywords/_browsermanagement.py +++ b/src/Selenium2Library/keywords/_browsermanagement.py @@ -114,7 +114,7 @@ def open_browser(self, url, browser='firefox', alias=None,remote_url=False, % browser.session_id) return self._cache.register(browser, alias) - def create_webdriver(self, driver_name, alias=None, *name_value_pairs, **init_kwargs): + def create_webdriver(self, driver_name, alias=None, kwargs={}, **init_kwargs): """Creates an instance of a WebDriver. Like `Open Browser`, but allows passing arguments to a WebDriver's @@ -133,31 +133,31 @@ def create_webdriver(self, driver_name, alias=None, *name_value_pairs, **init_kw Use keyword arguments to specify the arguments you want to pass to the WebDriver's __init__. The values of the arguments are not processed in any way before being passed on. For Robot Framework - < 2.8, which does not support keyword arguments, use a list of - argument names and value to specify the arguments instead . See the + < 2.8, which does not support keyword arguments, create a keyword + dictionary and pass it in as argument `kwargs`. See the [http://selenium.googlecode.com/git/docs/api/py/api.html|Selenium API Documentation] for information about argument names and appropriate argument values. Examples: - | # use proxy for Firefox | | | | - | ${proxy}= | Evaluate | sys.modules['selenium.webdriver'].Proxy() | sys, selenium.webdriver | - | ${proxy.http_proxy}= | Set Variable | localhost:8888 | | - | Create Webdriver | Firefox | proxy=${proxy} | | - | # debug IE driver | | | | - | Create Webdriver | Ie | log_level=DEBUG | log_file=%{HOMEPATH}${/}ie.log | + | # use proxy for Firefox | | | | + | ${proxy}= | Evaluate | sys.modules['selenium.webdriver'].Proxy() | sys, selenium.webdriver | + | ${proxy.http_proxy}= | Set Variable | localhost:8888 | | + | Create Webdriver | Firefox | proxy=${proxy} | | + | # use a proxy for PhantomJS | | | | + | ${service args}= | Create List | --proxy=192.168.132.104:8888 | | + | Create Webdriver | PhantomJS | service_args=${service args} | | Example for Robot Framework < 2.8: - | # use a proxy for PhantomJS | | | | | - | ${service args}= | Create List | --proxy=192.168.132.104:8888 | | | - | Create Webdriver | PhantomJS | phantomjs | service_args | ${service args} | + | # debug IE driver | | | | | | + | ${kwargs}= | Create Dictionary | log_level | DEBUG | log_file | %{HOMEPATH}${/}ie.log | + | Create Webdriver | Ie | kwargs=${kwargs} | | | | """ - if len(name_value_pairs) % 2 != 0: - raise RuntimeError("There should be an even number of argument name-value pairs.") - for i in range(0, len(name_value_pairs), 2): - arg_name = name_value_pairs[i].strip() + if not isinstance(kwargs, dict): + raise RuntimeError("kwargs must be a dictionary.") + for arg_name in kwargs: if arg_name in init_kwargs: raise RuntimeError("Got multiple values for argument '%s'." % arg_name) - init_kwargs[arg_name] = name_value_pairs[i+1] + init_kwargs[arg_name] = kwargs[arg_name] driver_name = driver_name.strip() try: creation_func = getattr(webdriver, driver_name) diff --git a/test/acceptance/create_webdriver.txt b/test/acceptance/create_webdriver.txt index eb274955d..8a8d0b86e 100644 --- a/test/acceptance/create_webdriver.txt +++ b/test/acceptance/create_webdriver.txt @@ -1,35 +1,30 @@ *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 firefox + ${index}= Create Webdriver Firefox 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 firefox + Switch Browser createwebdriver [Teardown] Close Browser -Create Webdriver With Missing Value - Run Keyword And Expect Error There should be an even number of argument name-value pairs. Create Webdriver Firefox firefox proxy - Create Webdriver With Keyword Argument - ${proxy}= Evaluate sys.modules['selenium.webdriver'].Proxy() sys, selenium.webdriver - ${proxy.http_proxy}= Set Variable localhost:7777 + ${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 List Argument - ${proxy}= Evaluate sys.modules['selenium.webdriver'].Proxy() sys, selenium.webdriver - ${proxy.http_proxy}= Set Variable localhost:7777 - Create Webdriver Firefox firefox proxy ${proxy} +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 @@ -38,6 +33,14 @@ Create Webdriver With Bad Driver Name Run Keyword And Expect Error 'Fireox' is not a valid WebDriver name Create Webdriver Fireox Create Webdriver With Duplicate Arguments - Run Keyword And Expect Error Got multiple values for argument 'arg'. Create Webdriver Firefox firefox arg 1 arg=2 - Run Keyword And Expect Error Got multiple values for argument 'arg'. Create Webdriver Firefox firefox arg 1 arg 2 - \ No newline at end of file + ${kwargs}= Create Dictionary arg 1 + Run Keyword And Expect Error Got multiple values for argument 'arg'. Create Webdriver Firefox kwargs=${kwargs} arg=2 + +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} From 07005979668c098762bda0f9d6ad017da0153af5 Mon Sep 17 00:00:00 2001 From: Kevin Ormbrek Date: Thu, 7 Nov 2013 23:27:52 -0600 Subject: [PATCH 4/6] move some testing to unit tests acceptance test opens browser passed to run_tests.py --- test/acceptance/create_webdriver.txt | 32 +++++--------------- test/unit/keywords/test_browsermanagement.py | 28 +++++++++++++++++ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/test/acceptance/create_webdriver.txt b/test/acceptance/create_webdriver.txt index 8a8d0b86e..1e5400802 100644 --- a/test/acceptance/create_webdriver.txt +++ b/test/acceptance/create_webdriver.txt @@ -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} diff --git a/test/unit/keywords/test_browsermanagement.py b/test/unit/keywords/test_browsermanagement.py index 3c7ffa75b..d35fc251e 100644 --- a/test/unit/keywords/test_browsermanagement.py +++ b/test/unit/keywords/test_browsermanagement.py @@ -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) From 922c3c7b708948fd5ded332ff2999e732c0bf5d8 Mon Sep 17 00:00:00 2001 From: Kevin Ormbrek Date: Fri, 8 Nov 2013 11:42:25 -0600 Subject: [PATCH 5/6] test that alias is used accidentally dropped this coverage in last commit --- test/unit/keywords/test_browsermanagement.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/keywords/test_browsermanagement.py b/test/unit/keywords/test_browsermanagement.py index d35fc251e..0e229192d 100644 --- a/test/unit/keywords/test_browsermanagement.py +++ b/test/unit/keywords/test_browsermanagement.py @@ -95,10 +95,11 @@ def __init__(self, some_arg=None): capt_data['webdriver'] = self webdriver.FakeWebDriver = FakeWebDriver try: - index = bm.create_webdriver('FakeWebDriver', some_arg=1) + index = bm.create_webdriver('FakeWebDriver', 'fake', 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)) + self.assertEquals(capt_data['webdriver'], bm._cache.get_connection('fake')) capt_data.clear() my_kwargs = {'some_arg':2} bm.create_webdriver('FakeWebDriver', kwargs=my_kwargs) From c00bdacf5c55e797ebea4227ce0247cc6ff8a1b2 Mon Sep 17 00:00:00 2001 From: Kevin Ormbrek Date: Sat, 16 Nov 2013 16:45:08 -0600 Subject: [PATCH 6/6] add missing aliases and support remote webdrivers --- test/acceptance/create_webdriver.txt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/acceptance/create_webdriver.txt b/test/acceptance/create_webdriver.txt index 1e5400802..7aba6256e 100644 --- a/test/acceptance/create_webdriver.txt +++ b/test/acceptance/create_webdriver.txt @@ -5,8 +5,8 @@ Library Collections *Test Cases* Create Webdriver Creates Functioning WebDriver [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 + [Setup] Set Driver Variables + Create Webdriver ${DRIVER_NAME} kwargs=${KWARGS} Go To ${FRONT PAGE} Page Should Contain needle [Teardown] Close Browser @@ -22,7 +22,14 @@ Create Webdriver With Bad Keyword Argument Dictionary Run Keyword And Expect Error kwargs must be a dictionary. Create Webdriver Firefox kwargs={'spam': 'eggs'} *Keywords* -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} +Set Driver Variables + ${drivers}= Create Dictionary ff Firefox firefox Firefox ie Ie internetexplorer Ie googlechrome Chrome gc Chrome chome Chrome opera Opera phantomjs PhantomJS safari Safari + ${name}= Evaluate "Remote" if "${REMOTE_URL}"!="None" else ${drivers}["${BROWSER.lower().replace(' ', '')}"] + Set Test Variable ${DRIVER_NAME} ${name} + ${dc names}= Create Dictionary ff FIREFOX firefox FIREFOX ie INTERNETEXPLORER internetexplorer INTERNETEXPLORER googlechrome CHROME gc CHROME opera OPERA phantomjs PHANTOMJS htmlunit HTMLUNIT htmlunitwithjs HTMLUNITWITHJS android ANDROID iphone IPHONE safari SAFARI + ${dc name}= Get From Dictionary ${dc names} ${BROWSER.lower().replace(' ', '')} + ${caps}= Evaluate sys.modules['selenium.webdriver'].DesiredCapabilities.${dc name} selenium.webdriver,sys + ${url as str}= Evaluate str('${REMOTE_URL}') # cannot be unicode for several versions >= 2.32 + ${kwargs}= Create Dictionary + Run Keyword If "${name}"=="Remote" Set To Dictionary ${kwargs} command_executor ${url as str} desired_capabilities ${caps} + Set Test Variable ${KWARGS} ${kwargs}