From b6cd170407e8e735ba3568bce36974fb393612a2 Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Sun, 7 Jun 2015 20:55:56 +0300 Subject: [PATCH 01/24] When screen shot is taken file is not overwritten When screen shot is taken and if the file allready exit, the file name is changed to contain -001 in the end. Example foobar.png is changed to: foobar-1.png --- src/Selenium2Library/keywords/_screenshot.py | 95 +++++++++++++++----- test/acceptance/keywords/screenshots.robot | 27 ++++++ 2 files changed, 101 insertions(+), 21 deletions(-) diff --git a/src/Selenium2Library/keywords/_screenshot.py b/src/Selenium2Library/keywords/_screenshot.py index 7c2c8a480..27a226b38 100644 --- a/src/Selenium2Library/keywords/_screenshot.py +++ b/src/Selenium2Library/keywords/_screenshot.py @@ -8,7 +8,7 @@ class _ScreenshotKeywords(KeywordGroup): def __init__(self): - self._screenshot_index = 0 + self._screenshot_index = {} self._screenshot_path_stack = [] self.screenshot_root_directory = None @@ -32,30 +32,57 @@ def set_screenshot_directory(self, path, persist=False): self.screenshot_root_directory = path - def capture_page_screenshot(self, filename=None): + def capture_page_screenshot(self, filename=None, overwrite=False): """Takes a screenshot of the current page and embeds it into the log. `filename` argument specifies the name of the file to write the - screenshot into. If no `filename` is given, the screenshot is saved into file - `selenium-screenshot-.png` under the directory where - the Robot Framework log file is written into. The `filename` is + screenshot into. If no `filename` is given, the screenshot is + saved into file `selenium-screenshot-.png` under the directory + where the Robot Framework log file is written into. The `filename` is also considered relative to the same directory, if it is not given in absolute format. If an absolute or relative path is given but the path does not exist it will be created. - `css` can be used to modify how the screenshot is taken. By default - the bakground color is changed to avoid possible problems with - background leaking when the page layout is somehow broken. + With `overwrite` it is possible to define what is done if file already + exist. By default filename is not overwritten but new one is created + by adding in the end. Example if capture.png exist and + this is the first overwrite, then new file is created with name + capture-1.png + + Example: + | Open Browser | www.someurl.com | browser=${BROWSER} | + | Capture Page Screenshot | filename=${BROWSER} | + | Capture Page Screenshot | filename=${BROWSER} | + | Capture Page Screenshot | filename=${BROWSER} | + | File Should Exist | ${OUTPUTDIR}${/}${BROWSER}.png | + | File Should Exist | ${OUTPUTDIR}${/}${BROWSER}-1.png | + | File Should Exist | ${OUTPUTDIR}${/}${BROWSER}-2.png | + | Capture Page Screenshot | + | Capture Page Screenshot | + | File Should Exist | ${OUTPUTDIR}${/}selenium-screenshot-1.png | + | File Should Exist | ${OUTPUTDIR}${/}selenium-screenshot-2.png | + | Capture Page Screenshot | filename=DefaultName.png | overwrite=${True} | + | Capture Page Screenshot | filename=DefaultName.png | overwrite=${True} | + | File Should Exist | ${OUTPUTDIR}${/}DefaultName.png | + | File Should Not Exist | ${OUTPUTDIR}${/}DefaultName-1.png | + + *NOTE:* The `overwrite` is ignored if `filename` is not defined + Example: + | Open Browser | www.someurl.com | browser=${BROWSER} | + | Capture Page Screenshot | overwrite=${True} | # overwrite is ignored | + | Capture Page Screenshot | overwrite=${True} | # overwrite is ignored | + | File Should Exist | ${OUTPUTDIR}${/}selenium-screenshot-1.png | + | File Should Exist | ${OUTPUTDIR}${/}selenium-screenshot-2.png | """ - path, link = self._get_screenshot_paths(filename) - self._create_directory(path) + path, link = self._get_screenshot_paths(filename, overwrite=overwrite) + self._create_directory(path) if hasattr(self._current_browser(), 'get_screenshot_as_file'): - if not self._current_browser().get_screenshot_as_file(path): - raise RuntimeError('Failed to save screenshot ' + filename) + if not self._current_browser().get_screenshot_as_file(path): + raise RuntimeError('Failed to save screenshot ' + filename) else: - if not self._current_browser().save_screenshot(path): - raise RuntimeError('Failed to save screenshot ' + filename) + if not self._current_browser().save_screenshot(path): + raise RuntimeError('Failed to save screenshot ' + filename) # Image is shown on its own row and thus prev row is closed on purpose self._html('' @@ -86,15 +113,41 @@ def _get_screenshot_directory(self): def _restore_screenshot_directory(self): self.screenshot_root_directory = self._screenshot_path_stack.pop() - def _get_screenshot_paths(self, filename): + def _get_screenshot_paths(self, filename, overwrite=False): if not filename: - self._screenshot_index += 1 - filename = 'selenium-screenshot-%d.png' % self._screenshot_index + index = self._get_new_index('selenium-screenshot') + filename = 'selenium-screenshot-%d.png' % index + elif filename and not overwrite: + filename = self._screenshot_existence(filename.replace('/', + os.sep)) else: filename = filename.replace('/', os.sep) - screenshotDir = self._get_screenshot_directory() - logDir = self._get_log_dir() - path = os.path.join(screenshotDir, filename) - link = robot.utils.get_link_path(path, logDir) + screenshot_dir = self._get_screenshot_directory() + logdir = self._get_log_dir() + path = os.path.join(screenshot_dir, filename) + link = robot.utils.get_link_path(path, logdir) return path, link + + def _screenshot_existence(self, filename): + if os.path.exists(self._get_logdir_path(filename)[0]): + index = self._get_new_index(filename) + try: + return '-%s.png'.join(filename.rsplit('.png', 1)) % index + except TypeError: + return filename + '-%s' % index + else: + return filename + + def _get_logdir_path(self, filename): + logdir = self._get_log_dir() + return os.path.join(logdir, filename), logdir + + def _get_new_index(self, filename): + try: + index = self._screenshot_index[filename] + 1 + self._screenshot_index[filename] = index + return index + except KeyError: + self._screenshot_index[filename] = 1 + return 1 diff --git a/test/acceptance/keywords/screenshots.robot b/test/acceptance/keywords/screenshots.robot index 709097780..05207c8ed 100644 --- a/test/acceptance/keywords/screenshots.robot +++ b/test/acceptance/keywords/screenshots.robot @@ -42,3 +42,30 @@ Ensure screenshot captures revert to default root directory [Setup] Remove Files ${OUTPUTDIR}/default-root-screenshot.png Capture Page Screenshot default-root-screenshot.png File Should Exist ${OUTPUTDIR}/default-root-screenshot.png + +Capture page screenshot to with overwrite false and custom name + [Setup] Remove Directory ${OUTPUTDIR}/screenshot-overwrite recursive + Capture Page Screenshot screenshot-overwrite/some-name.png + File Should Exist ${OUTPUTDIR}/screenshot-overwrite/some-name.png + Capture Page Screenshot screenshot-overwrite/some-name.png + File Should Exist ${OUTPUTDIR}/screenshot-overwrite/some-name-1.png + +Capture page screenshot to with overwrite true + Capture Page Screenshot overwrite=True + Capture Page Screenshot overwrite=True + File Should Exist ${OUTPUTDIR}/selenium-screenshot-3.png + File Should Exist ${OUTPUTDIR}/selenium-screenshot-4.png + Capture Page Screenshot overwrite-filename.png overwrite=True + Capture Page Screenshot overwrite-filename.png overwrite=True + File Should Exist ${OUTPUTDIR}/overwrite-filename.png + File Should Not Exist ${OUTPUTDIR}/overwrite-filename-1.png + +Capture page screenshot with complex names + Capture Page Screenshot many.png.and.dots.png + Capture Page Screenshot many.png.and.dots.png + File Should Exist ${OUTPUTDIR}/many.png.and.dots.png + File Should Exist ${OUTPUTDIR}/many.png.and.dots-1.png + Capture Page Screenshot no-png-in-end + Capture Page Screenshot no-png-in-end + File Should Exist ${OUTPUTDIR}/no-png-in-end + File Should Exist ${OUTPUTDIR}/no-png-in-end-1 From a0305b91ade2b5a1d1fcf13f3e21ee2e4fef829a Mon Sep 17 00:00:00 2001 From: zephraph Date: Fri, 24 Jul 2015 23:37:24 -0500 Subject: [PATCH 02/24] Ensure RobotRunningError exists before using it --- src/Selenium2Library/keywords/_logging.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Selenium2Library/keywords/_logging.py b/src/Selenium2Library/keywords/_logging.py index 7080c8641..4d33d2f7a 100644 --- a/src/Selenium2Library/keywords/_logging.py +++ b/src/Selenium2Library/keywords/_logging.py @@ -3,7 +3,12 @@ from robot.api import logger from keywordgroup import KeywordGroup from robot.libraries.BuiltIn import BuiltIn -from robot.libraries.BuiltIn import RobotNotRunningError + +try: + from robot.libraries.BuiltIn import RobotNotRunningError +except ImportError: + RobotNotRunningError = AttributeError + class _LoggingKeywords(KeywordGroup): From f8cd314b4d27f05f76e37cc5578e8214fcab5ef1 Mon Sep 17 00:00:00 2001 From: zephraph Date: Mon, 27 Jul 2015 22:41:13 -0500 Subject: [PATCH 03/24] Fixed some of the intro documentation --- src/Selenium2Library/__init__.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Selenium2Library/__init__.py b/src/Selenium2Library/__init__.py index da5696fc1..3a481a883 100644 --- a/src/Selenium2Library/__init__.py +++ b/src/Selenium2Library/__init__.py @@ -33,7 +33,8 @@ class Selenium2Library( imported into your Robot test suite (see `importing` section), and the `Open Browser` keyword must be used to open a browser to the desired location. - **--- Note important change starting with Version 1.7.0 release ---** + + *--- Note important change starting with Version 1.7.0 release ---* = Locating or specifying elements = All keywords in Selenium2Library that need to find an element on the page @@ -42,14 +43,14 @@ class Selenium2Library( specifying different location strategies. `webelement` is a variable that holds a WebElement instance, which is a representation of the element. - Using 'locator' + *Using locators* --------------- By default, when a locator value is provided, it is matched against the key attributes of the particular element type. For example, `id` and `name` are key attributes to all elements, and locating elements is easy - using just the `id` as a `locator`. For example:: + using just the `id` as a `locator`. For example: - Click Element my_element + | Click Element my_element It is also possible to specify the approach Selenium2Library should take to find an element by specifying a lookup strategy with a locator @@ -76,14 +77,14 @@ class Selenium2Library( This can be fixed by changing the locator to: | Click Link default=page?a=b - Using 'webelement' + *Using webelements* ------------------ Starting with version 1.7 of the Selenium2Library, one can pass an argument that contains a WebElement instead of a string locator. To get a WebElement, use the new `Get WebElements` keyword. For example: - | ${elem} = | Get WebElements | id=my_element | - | Click Element | ${elem} | | + | ${elem} = | Get WebElement | id=my_element | + | Click Element | ${elem} | | Locating Tables, Table Rows, Columns, etc. ------------------------------------------ @@ -91,7 +92,7 @@ class Selenium2Library( By default, when a table locator value is provided, it will search for a table with the specified `id` attribute. For example: - Table Should Contain my_table text + | Table Should Contain my_table text More complex table lookup strategies are also supported: @@ -113,7 +114,7 @@ class Selenium2Library( to the WebDriver instance and `${criteria}` is the text of the locator (i.e. everything that comes after the = sign). To use this locator it must first be registered with `Add Location Strategy`. - Add Location Strategy custom Custom Locator Strategy + | Add Location Strategy custom Custom Locator Strategy The first argument of `Add Location Strategy` specifies the name of the lookup strategy (which must be unique). After registration of the lookup strategy, the usage is the same as other locators. See `Add Location Strategy` for more details. From d68baa98bae0fb325583356a74dafe63114a9318 Mon Sep 17 00:00:00 2001 From: zephraph Date: Mon, 27 Jul 2015 23:14:53 -0500 Subject: [PATCH 04/24] Added keyword 'Get WebElement' --- src/Selenium2Library/keywords/_element.py | 11 +++++++++-- test/acceptance/keywords/elements.robot | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py index 5a2cf7470..95159309b 100644 --- a/src/Selenium2Library/keywords/_element.py +++ b/src/Selenium2Library/keywords/_element.py @@ -21,6 +21,13 @@ def __init__(self): # Public, get element(s) + def get_webelement(self, locator): + """Returns the first WebElement matching the given locator. + + See `introduction` for details about locating elements. + """ + return self.get_webelements(locator)[0] + def get_webelements(self, locator): """Returns list of WebElement objects matching locator. @@ -599,7 +606,7 @@ def get_matching_xpath_count(self, xpath): """Returns number of elements matching `xpath` One should not use the xpath= prefix for 'xpath'. XPath is assumed. - + Correct: | count = | Get Matching Xpath Count | //div[@id='sales-pop'] Incorrect: @@ -615,7 +622,7 @@ def xpath_should_match_x_times(self, xpath, expected_xpath_count, message='', lo """Verifies that the page contains the given number of elements located by the given `xpath`. One should not use the xpath= prefix for 'xpath'. XPath is assumed. - + Correct: | Xpath Should Match X Times | //div[@id='sales-pop'] | 1 Incorrect: diff --git a/test/acceptance/keywords/elements.robot b/test/acceptance/keywords/elements.robot index 4e7c731f1..bb4adfcef 100644 --- a/test/acceptance/keywords/elements.robot +++ b/test/acceptance/keywords/elements.robot @@ -7,6 +7,13 @@ Get Elements @{links}= Get WebElements //div[@id="div_id"]/a Length Should Be ${links} 11 +Get First Matching Element + @{links}= Get WebElements //div[@id="div_id"]/a + ${link}= Get WebElement //div[@id="div_id"]/a + LOG @{links}[0] + LOG ${link} + Should Be Equal @{links}[0] ${link} + More Get Elements [Setup] Go To Page "forms/prefilled_email_form.html" @{checkboxes}= Get WebElements //input[@type="checkbox"] @@ -51,4 +58,3 @@ Get Vertical Position ${pos}= Get Vertical Position link=Link Should Be True ${pos} > ${0} Run Keyword And Expect Error Could not determine position for 'non-existent' Get Horizontal Position non-existent - From ccd2e93af0f82ba9967d74f8ab36511df0f278c5 Mon Sep 17 00:00:00 2001 From: HelioGuilherme66 Date: Wed, 29 Jul 2015 00:05:25 +0100 Subject: [PATCH 05/24] Add named keys to Press Key. --- src/Selenium2Library/keywords/_element.py | 9 ++- test/acceptance/keywords/textfields.robot | 67 +++++++++++++---------- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py index 95159309b..fef6a5250 100644 --- a/src/Selenium2Library/keywords/_element.py +++ b/src/Selenium2Library/keywords/_element.py @@ -490,10 +490,13 @@ def press_key(self, locator, key): lead by '\\\\'. Examples: - | Press Key | text_field | q | - | Press Key | login_button | \\\\13 | # ASCII code for enter key | + | Press Key | text_field | q | | + | Press Key | login_button | \\\\13 | # ASCII code for enter key | + | Press Key | nav_console | \\\\\\\\ARROW_UP | # selenium.webdriver.common.keys ARROW_UP KEY | """ - if key.startswith('\\') and len(key) > 1: + if key.startswith('\\\\') and len(key) > 1: + key = getattr(Keys,key[2:]) + elif key.startswith('\\') and len(key) > 1: key = self._map_ascii_key_code_to_key(int(key[1:])) #if len(key) > 1: # raise ValueError("Key value '%s' is invalid.", key) diff --git a/test/acceptance/keywords/textfields.robot b/test/acceptance/keywords/textfields.robot index 6e0f82c6a..c224ac924 100644 --- a/test/acceptance/keywords/textfields.robot +++ b/test/acceptance/keywords/textfields.robot @@ -1,40 +1,49 @@ -*Setting* -Variables variables.py -Resource ../resource.robot -Test Setup Go To Page "forms/prefilled_email_form.html" - - -*Test Cases* +*** Setting *** +Test Setup Go To Page "forms/prefilled_email_form.html" +Force Tags txtfields +Variables variables.py +Resource ../resource.robot +*** Test Cases *** Get Value From Text Field - ${text} = Get Value name - Should Be Equal ${text} Prefilled Name - Clear Element Text name - ${text} = Get Value name - Should Be Equal ${text} ${EMPTY} + ${text} = Get Value name + Should Be Equal ${text} Prefilled Name + Clear Element Text name + ${text} = Get Value name + Should Be Equal ${text} ${EMPTY} Input Unicode In Text Field - Input Text name ${unic_text} - ${text} = Get Value name - Should Be Equal ${text} ${unic_text} + Input Text name ${unic_text} + ${text} = Get Value name + Should Be Equal ${text} ${unic_text} Input Password - [Documentation] LOG 3 Typing password into text field 'password_field' - [Setup] Go To Page "forms/login.html" - Input Text username_field username - Input Password password_field password - Submit Form - Verify Location Is "forms/submit.html" + [Documentation] LOG 3 Typing password into text field 'password_field' + [Setup] Go To Page "forms/login.html" + Input Text username_field username + Input Password password_field password + Submit Form + Verify Location Is "forms/submit.html" Press Key - [Setup] Go To Page "forms/login.html" - Cannot Be Executed in IE - Input Text username_field James Bond - Press Key password_field f - Press Key password_field \\9 - Press Key login_button \\10 - Verify Location Is "forms/submit.html" + [Setup] Go To Page "forms/login.html" + #Cannot Be Executed in IE + Input Text username_field James Bond + Press Key username_field \\\\HOME + Press Key username_field \\\\END + Press Key username_field \\\\ARROW_LEFT + Press Key username_field \\\\ARROW_LEFT + Press Key username_field \\\\ARROW_LEFT + Press Key username_field \\\\ARROW_LEFT + Press Key username_field \\\\ARROW_RIGHT + Press Key username_field \\108 #This is the 'l' char + ${text} = Get Value username_field + Should Be Equal ${text} James Blond + Press Key password_field f + Press Key password_field \\9 + Press Key login_button \\10 + Verify Location Is "forms/submit.html" Attempt Clear Element Text On Non-Editable Field - Run Keyword And Expect Error * Clear Element Text can_send_email + Run Keyword And Expect Error * Clear Element Text can_send_email From dd40725311fd5726ca3621336450a06c3a20f7b6 Mon Sep 17 00:00:00 2001 From: Helio Guilherme Date: Wed, 29 Jul 2015 15:11:29 +0100 Subject: [PATCH 06/24] Deprecates the use of backslash escaping for ASCII and NAMED Keys. --- src/Selenium2Library/keywords/_element.py | 40 ++++++++++++++++------- test/acceptance/keywords/textfields.robot | 22 +++++++------ 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py index fef6a5250..21984ba0d 100644 --- a/src/Selenium2Library/keywords/_element.py +++ b/src/Selenium2Library/keywords/_element.py @@ -486,20 +486,27 @@ def simulate(self, locator, event): def press_key(self, locator, key): """Simulates user pressing key on element identified by `locator`. - `key` is either a single character, or a numerical ASCII code of the key - lead by '\\\\'. + `key` is either a single character, a numerical ASCII code of the key,\ + or a NAMED KEY as described at https://selenium.googlecode.com/git/docs/api/py/webdriver/selenium.webdriver.common.keys.html Examples: - | Press Key | text_field | q | | - | Press Key | login_button | \\\\13 | # ASCII code for enter key | - | Press Key | nav_console | \\\\\\\\ARROW_UP | # selenium.webdriver.common.keys ARROW_UP KEY | - """ - if key.startswith('\\\\') and len(key) > 1: - key = getattr(Keys,key[2:]) - elif key.startswith('\\') and len(key) > 1: - key = self._map_ascii_key_code_to_key(int(key[1:])) - #if len(key) > 1: - # raise ValueError("Key value '%s' is invalid.", key) + | Press Key | text_field | q | | + | Press Key | login_button | \\\\13 | # ASCII code for Enter key (DEPRECATED) | + | Press Key | login_button | 10 | # ASCII code for Return key | + | Press Key | nav_console | ARROW_UP | # selenium.webdriver.common.keys ARROW_UP KEY | + + NAMED KEY value is new in Selenium2Library 1.7.3. + """ + if len(key) > 1: + if key.startswith('\\'): + self._warn("Press Key: Escaped ASCII codes are deprecated. Use plain numeric value: '%s'" % (key[1:])) + key = self._map_ascii_key_code_to_key(int(key[1:])) + else: + try: + key = (key.isdecimal() and self._map_ascii_key_code_to_key(int(key))) or\ + ((not key.isdecimal()) and self._map_named_key_code_to_special_key(key)) + except: + raise ValueError("Key value '%s' is invalid." % (key)) element = self._element_find(locator, True, True) #select it element.send_keys(key) @@ -758,6 +765,15 @@ def _map_ascii_key_code_to_key(self, key_code): key = chr(key_code) return key + def _map_named_key_code_to_special_key(self, key_name): + try: + return getattr(Keys, key_name) + except: + message = "Unknown key named '%s'." % (key_name) + self._debug(message) + raise ValueError(message) + return Keys.NULL + def _parse_attribute_locator(self, attribute_locator): parts = attribute_locator.rpartition('@') if len(parts[0]) == 0: diff --git a/test/acceptance/keywords/textfields.robot b/test/acceptance/keywords/textfields.robot index c224ac924..72f0ac2b1 100644 --- a/test/acceptance/keywords/textfields.robot +++ b/test/acceptance/keywords/textfields.robot @@ -30,19 +30,21 @@ Press Key [Setup] Go To Page "forms/login.html" #Cannot Be Executed in IE Input Text username_field James Bond - Press Key username_field \\\\HOME - Press Key username_field \\\\END - Press Key username_field \\\\ARROW_LEFT - Press Key username_field \\\\ARROW_LEFT - Press Key username_field \\\\ARROW_LEFT - Press Key username_field \\\\ARROW_LEFT - Press Key username_field \\\\ARROW_RIGHT - Press Key username_field \\108 #This is the 'l' char + Press Key username_field HOME + Press Key username_field END + Press Key username_field ARROW_LEFT + Press Key username_field ARROW_LEFT + Press Key username_field ARROW_LEFT + Press Key username_field DELETE + Press Key username_field ARROW_LEFT + Press Key username_field ARROW_RIGHT + Press Key username_field \\108 #This is the 'l' char (deprecated style) + Press Key username_field 111 #This is the 'o' char ${text} = Get Value username_field Should Be Equal ${text} James Blond Press Key password_field f - Press Key password_field \\9 - Press Key login_button \\10 + Press Key password_field 9 + Press Key login_button 10 Verify Location Is "forms/submit.html" Attempt Clear Element Text On Non-Editable Field From d64c4b8dde11c7e60aa1df87b409f077f4bfdfb9 Mon Sep 17 00:00:00 2001 From: zephraph Date: Wed, 29 Jul 2015 11:02:44 -0500 Subject: [PATCH 07/24] Fixes suggested by pekka --- src/Selenium2Library/keywords/_element.py | 20 +++++++------------- test/acceptance/keywords/textfields.robot | 8 ++++---- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py index 21984ba0d..a06534370 100644 --- a/src/Selenium2Library/keywords/_element.py +++ b/src/Selenium2Library/keywords/_element.py @@ -486,29 +486,23 @@ def simulate(self, locator, event): def press_key(self, locator, key): """Simulates user pressing key on element identified by `locator`. - `key` is either a single character, a numerical ASCII code of the key,\ + `key` is either a single character, a numerical ASCII code of the key lead by '\\\\', or a NAMED KEY as described at https://selenium.googlecode.com/git/docs/api/py/webdriver/selenium.webdriver.common.keys.html Examples: - | Press Key | text_field | q | | - | Press Key | login_button | \\\\13 | # ASCII code for Enter key (DEPRECATED) | - | Press Key | login_button | 10 | # ASCII code for Return key | + | Press Key | text_field | q | # The letter 'q' | + | Press Key | login_button | \\\\13 | # ASCII code for Enter key | | Press Key | nav_console | ARROW_UP | # selenium.webdriver.common.keys ARROW_UP KEY | - + NAMED KEY value is new in Selenium2Library 1.7.3. """ if len(key) > 1: if key.startswith('\\'): - self._warn("Press Key: Escaped ASCII codes are deprecated. Use plain numeric value: '%s'" % (key[1:])) key = self._map_ascii_key_code_to_key(int(key[1:])) else: - try: - key = (key.isdecimal() and self._map_ascii_key_code_to_key(int(key))) or\ - ((not key.isdecimal()) and self._map_named_key_code_to_special_key(key)) - except: - raise ValueError("Key value '%s' is invalid." % (key)) + key = self._map_named_key_code_to_special_key(key) element = self._element_find(locator, True, True) - #select it + # select it element.send_keys(key) # Public, links @@ -768,7 +762,7 @@ def _map_ascii_key_code_to_key(self, key_code): def _map_named_key_code_to_special_key(self, key_name): try: return getattr(Keys, key_name) - except: + except AttributeError: message = "Unknown key named '%s'." % (key_name) self._debug(message) raise ValueError(message) diff --git a/test/acceptance/keywords/textfields.robot b/test/acceptance/keywords/textfields.robot index 72f0ac2b1..3c5496a43 100644 --- a/test/acceptance/keywords/textfields.robot +++ b/test/acceptance/keywords/textfields.robot @@ -11,7 +11,7 @@ Get Value From Text Field Clear Element Text name ${text} = Get Value name Should Be Equal ${text} ${EMPTY} - + Input Unicode In Text Field Input Text name ${unic_text} @@ -38,13 +38,13 @@ Press Key Press Key username_field DELETE Press Key username_field ARROW_LEFT Press Key username_field ARROW_RIGHT - Press Key username_field \\108 #This is the 'l' char (deprecated style) - Press Key username_field 111 #This is the 'o' char + Press Key username_field \\108 #This is the 'l' char + Press Key username_field o ${text} = Get Value username_field Should Be Equal ${text} James Blond Press Key password_field f Press Key password_field 9 - Press Key login_button 10 + Press Key login_button ENTER Verify Location Is "forms/submit.html" Attempt Clear Element Text On Non-Editable Field From 67a9133580c81678644c4790888983c0a25072bc Mon Sep 17 00:00:00 2001 From: zephraph Date: Wed, 29 Jul 2015 17:41:03 -0500 Subject: [PATCH 08/24] Fix documentation, small bugs --- src/Selenium2Library/keywords/_element.py | 7 ++++--- test/acceptance/keywords/textfields.robot | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py index a06534370..2afdb9b11 100644 --- a/src/Selenium2Library/keywords/_element.py +++ b/src/Selenium2Library/keywords/_element.py @@ -487,12 +487,14 @@ def press_key(self, locator, key): """Simulates user pressing key on element identified by `locator`. `key` is either a single character, a numerical ASCII code of the key lead by '\\\\', - or a NAMED KEY as described at https://selenium.googlecode.com/git/docs/api/py/webdriver/selenium.webdriver.common.keys.html + or a NAMED KEY as described in the [https://selenium.googlecode.com/git/docs/api/py/webdriver/selenium.webdriver.common.keys.html|Selenium docs]. Examples: | Press Key | text_field | q | # The letter 'q' | + | Press Key | nav_console | ARROW_UP | # Named ARROW_UP key | | Press Key | login_button | \\\\13 | # ASCII code for Enter key | - | Press Key | nav_console | ARROW_UP | # selenium.webdriver.common.keys ARROW_UP KEY | + + It's recommended to use named keys over ascii escapes (.i.e ``ENTER`` over ``\\\\13``) NAMED KEY value is new in Selenium2Library 1.7.3. """ @@ -766,7 +768,6 @@ def _map_named_key_code_to_special_key(self, key_name): message = "Unknown key named '%s'." % (key_name) self._debug(message) raise ValueError(message) - return Keys.NULL def _parse_attribute_locator(self, attribute_locator): parts = attribute_locator.rpartition('@') diff --git a/test/acceptance/keywords/textfields.robot b/test/acceptance/keywords/textfields.robot index 3c5496a43..157fd7d19 100644 --- a/test/acceptance/keywords/textfields.robot +++ b/test/acceptance/keywords/textfields.robot @@ -1,6 +1,5 @@ *** Setting *** Test Setup Go To Page "forms/prefilled_email_form.html" -Force Tags txtfields Variables variables.py Resource ../resource.robot From d392a16ff5e9a1933f21c27eafddc6617c6fc9fc Mon Sep 17 00:00:00 2001 From: Ed Manlove Date: Sun, 2 Aug 2015 09:59:29 -0400 Subject: [PATCH 09/24] Refactor method for getting first web element. Added extra check for non-existing web element. --- src/Selenium2Library/keywords/_element.py | 2 +- test/acceptance/keywords/elements.robot | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Selenium2Library/keywords/_element.py b/src/Selenium2Library/keywords/_element.py index 2afdb9b11..f7e88eb02 100644 --- a/src/Selenium2Library/keywords/_element.py +++ b/src/Selenium2Library/keywords/_element.py @@ -26,7 +26,7 @@ def get_webelement(self, locator): See `introduction` for details about locating elements. """ - return self.get_webelements(locator)[0] + return self._element_find(locator, True, True) def get_webelements(self, locator): """Returns list of WebElement objects matching locator. diff --git a/test/acceptance/keywords/elements.robot b/test/acceptance/keywords/elements.robot index bb4adfcef..bcbdc7482 100644 --- a/test/acceptance/keywords/elements.robot +++ b/test/acceptance/keywords/elements.robot @@ -7,12 +7,14 @@ Get Elements @{links}= Get WebElements //div[@id="div_id"]/a Length Should Be ${links} 11 -Get First Matching Element +Get Web Element @{links}= Get WebElements //div[@id="div_id"]/a ${link}= Get WebElement //div[@id="div_id"]/a LOG @{links}[0] LOG ${link} Should Be Equal @{links}[0] ${link} + Run Keyword and Expect Error ValueError: Element locator 'id=non_existing_elem' did not match any elements. + ... Get WebElement id=non_existing_elem More Get Elements [Setup] Go To Page "forms/prefilled_email_form.html" From a0dcbef494fca1d1c8dfd7f896a44090bd3a4571 Mon Sep 17 00:00:00 2001 From: Ed Manlove Date: Mon, 3 Aug 2015 19:37:32 -0400 Subject: [PATCH 10/24] Removed logging. --- test/acceptance/keywords/elements.robot | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/acceptance/keywords/elements.robot b/test/acceptance/keywords/elements.robot index bcbdc7482..21706ce0a 100644 --- a/test/acceptance/keywords/elements.robot +++ b/test/acceptance/keywords/elements.robot @@ -10,8 +10,6 @@ Get Elements Get Web Element @{links}= Get WebElements //div[@id="div_id"]/a ${link}= Get WebElement //div[@id="div_id"]/a - LOG @{links}[0] - LOG ${link} Should Be Equal @{links}[0] ${link} Run Keyword and Expect Error ValueError: Element locator 'id=non_existing_elem' did not match any elements. ... Get WebElement id=non_existing_elem From b7a2619dd730304c6c011903bcbb7a61d8b16fcc Mon Sep 17 00:00:00 2001 From: zephraph Date: Mon, 3 Aug 2015 18:41:51 -0500 Subject: [PATCH 11/24] Update changelog --- CHANGES.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index e5fa6931d..3df9ee3dc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,10 @@ Release Notes ============= +1.7.3 (unreleased) +------------------- +- Added 'Get WebElement' [zephraph][emanlove] + 1.7.2 ---------------- - Added an argument called screenshot_root_directory that can be passed into S2L's From 286cf8311bbb520085b3780b503068ed4d11ae08 Mon Sep 17 00:00:00 2001 From: zephraph Date: Fri, 7 Aug 2015 17:21:44 -0500 Subject: [PATCH 12/24] prep for 1.7.3 release --- CHANGES.rst | 10 +++++++++- src/Selenium2Library/version.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3df9ee3dc..c3bf7ad3c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,10 +1,18 @@ Release Notes ============= -1.7.3 (unreleased) +1.7.3 ------------------- - Added 'Get WebElement' [zephraph][emanlove] +- Added named keys to 'Press Key' [helioguilherme66] + +- Fix an import error that caused a dependence on RF >= 2.8.5 + [zephraph] + +- Fixed an issue that caused screenshots to be improperly linked in the logs + [zephraph] + 1.7.2 ---------------- - Added an argument called screenshot_root_directory that can be passed into S2L's diff --git a/src/Selenium2Library/version.py b/src/Selenium2Library/version.py index 7b59fb64f..1d7f168ba 100644 --- a/src/Selenium2Library/version.py +++ b/src/Selenium2Library/version.py @@ -1 +1 @@ -VERSION = '1.7.2' +VERSION = '1.7.3' From 8fb931a3f7dbf6b04a54f3508de8c2673c463606 Mon Sep 17 00:00:00 2001 From: zephraph Date: Fri, 7 Aug 2015 17:28:00 -0500 Subject: [PATCH 13/24] Adding docs --- .gitignore | 1 - doc/Selenium2Library.html | 832 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 832 insertions(+), 1 deletion(-) create mode 100644 doc/Selenium2Library.html diff --git a/.gitignore b/.gitignore index 56284b44b..6f7b23439 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ test/results *.pyc *.orig MANIFEST -doc/*.html *.egg-info *.egg chromedriver.log diff --git a/doc/Selenium2Library.html b/doc/Selenium2Library.html new file mode 100644 index 000000000..8a65a34da --- /dev/null +++ b/doc/Selenium2Library.html @@ -0,0 +1,832 @@ + + + + + + + + + + + + + + + + + + + + + + +
+

Opening library documentation failed

+
    +
  • Verify that you have JavaScript enabled in your browser.
  • +
  • Make sure you are using a modern enough browser. Firefox 3.5, IE 8, or equivalent is required, newer browsers are recommended.
  • +
  • Check are there messages in your browser's JavaScript error log. Please report the problem if you suspect you have encountered a bug.
  • +
+
+ + + + + + + + + + + + + + + + + + + + + + From d5d1e07e810ee104d53a5b0aa29753d34e6398e6 Mon Sep 17 00:00:00 2001 From: zephraph Date: Tue, 11 Aug 2015 15:07:47 -0500 Subject: [PATCH 14/24] Updated docs --- doc/Selenium2Library.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Selenium2Library.html b/doc/Selenium2Library.html index 8a65a34da..f0d8d11d2 100644 --- a/doc/Selenium2Library.html +++ b/doc/Selenium2Library.html @@ -468,7 +468,7 @@ jQuery.extend({highlight:function(e,t,n,r){if(e.nodeType===3){var i=e.data.match(t);if(i){var s=document.createElement(n||"span");s.className=r||"highlight";var o=e.splitText(i.index);o.splitText(i[0].length);var u=o.cloneNode(true);s.appendChild(u);o.parentNode.replaceChild(s,o);return 1}}else if(e.nodeType===1&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&!(e.tagName===n.toUpperCase()&&e.className===r)){for(var a=0;a From c6dbd60e48e483ef344ae219da10f49eab259467 Mon Sep 17 00:00:00 2001 From: HelioGuilherme66 Date: Wed, 12 Aug 2015 01:16:50 +0100 Subject: [PATCH 15/24] Cleans up acceptance tests to be consistent. Reduces warnings and errors detected with rflint. --- test/acceptance/create_webdriver.robot | 68 +-- test/acceptance/keywords/__init__.robot | 8 +- .../keywords/async_javascript.robot | 141 +++--- .../keywords/checkbox_and_radio_buttons.robot | 73 ++-- test/acceptance/keywords/click_element.robot | 24 +- .../click_element_at_coordinates.robot | 4 +- .../keywords/content_assertions.robot | 400 +++++++++++------- test/acceptance/keywords/cookies.robot | 15 +- ...ement_should_be_enabled_and_disabled.robot | 74 ++-- test/acceptance/keywords/elements.robot | 93 ++-- .../keywords/forms_and_buttons.robot | 69 +-- test/acceptance/keywords/frames.robot | 81 ++-- test/acceptance/keywords/javascript.robot | 138 +++--- test/acceptance/keywords/lists.robot | 204 +++++---- test/acceptance/keywords/mouse.robot | 51 ++- test/acceptance/keywords/navigation.robot | 74 ++-- test/acceptance/keywords/run_on_failure.robot | 82 ++-- test/acceptance/keywords/screenshots.robot | 106 ++--- .../keywords/tables/col_should_contain.robot | 35 +- .../keywords/tables/finding_tables.robot | 2 + .../tables/footer_should_contain.robot | 26 +- .../keywords/tables/get_table_cell.robot | 56 ++- .../tables/header_should_contain.robot | 34 +- .../keywords/tables/negative_indexes.robot | 36 +- .../keywords/tables/row_should_contain.robot | 64 +-- .../keywords/tables/table_resource.robot | 18 +- .../tables/table_should_contain.robot | 77 ++-- test/acceptance/keywords/textfields.robot | 6 +- test/acceptance/keywords/waiting.robot | 98 +++-- test/acceptance/locators/custom.robot | 47 +- test/acceptance/locators/sizzle.robot | 4 + test/acceptance/multiple_browsers.robot | 47 +- test/acceptance/open_and_close.robot | 34 +- test/acceptance/resource.robot | 94 ++-- test/acceptance/windows.robot | 170 ++++---- 35 files changed, 1477 insertions(+), 1076 deletions(-) mode change 100755 => 100644 test/acceptance/keywords/run_on_failure.robot mode change 100755 => 100644 test/acceptance/resource.robot diff --git a/test/acceptance/create_webdriver.robot b/test/acceptance/create_webdriver.robot index 4bfff3db8..f588c1af6 100644 --- a/test/acceptance/create_webdriver.robot +++ b/test/acceptance/create_webdriver.robot @@ -1,35 +1,53 @@ -*Setting* -Resource resource.robot -Library Collections +*** Setting *** +Documentation Tests Webdriver +Resource resource.robot +Library Collections -*Test Cases* +*** Test Cases *** Create Webdriver Creates Functioning WebDriver - [Documentation] LOG 2:1 INFO REGEXP: Creating an instance of the \\w+ WebDriver LOG 2:4 DEBUG REGEXP: Created \\w+ WebDriver instance with session id (\\w|-)+ - [Setup] Set Driver Variables - Create Webdriver ${DRIVER_NAME} kwargs=${KWARGS} - Go To ${FRONT PAGE} - Page Should Contain needle - [Teardown] Close Browser + [Documentation] LOG 2:1 INFO REGEXP: Creating an instance of the \\w+ WebDriver + ... LOG 2:4 DEBUG REGEXP: Created \\w+ WebDriver instance with session id (\\w|-)+ + [Setup] Set Driver Variables + Create Webdriver ${DRIVER_NAME} kwargs=${KWARGS} + Go To ${FRONT PAGE} + Page Should Contain needle + [Teardown] Close Browser Create Webdriver With Bad Driver Name - Run Keyword And Expect Error 'Fireox' is not a valid WebDriver name Create Webdriver Fireox + [Documentation] Invalid browser name + Run Keyword And Expect Error 'Fireox' is not a valid WebDriver name + ... Create Webdriver Fireox Create Webdriver With Duplicate Arguments - ${kwargs}= Create Dictionary arg 1 - Run Keyword And Expect Error Got multiple values for argument 'arg'. Create Webdriver Firefox kwargs=${kwargs} arg=2 + [Documentation] Invalid values in arguments + ${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'} + [Documentation] Invalid arguments types + Run Keyword And Expect Error kwargs must be a dictionary. + ... Create Webdriver Firefox kwargs={'spam': 'eggs'} -*Keywords* +*** Keywords *** Set Driver Variables - ${drivers}= Create Dictionary ff Firefox firefox Firefox ie Ie internetexplorer Ie googlechrome Chrome gc Chrome chrome 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 chrome 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} + [Documentation] Selects proper driver + ${drivers}= Create Dictionary ff Firefox firefox Firefox ie + ... Ie internetexplorer Ie googlechrome Chrome gc + ... Chrome chrome 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 chrome 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 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} diff --git a/test/acceptance/keywords/__init__.robot b/test/acceptance/keywords/__init__.robot index 032a95bbe..58158758d 100644 --- a/test/acceptance/keywords/__init__.robot +++ b/test/acceptance/keywords/__init__.robot @@ -1,4 +1,4 @@ -*Setting* -Resource ../resource.robot -Suite Setup Open Browser To Start Page -Suite Teardown Close All Browsers +*** Settings *** +Resource ../resource.robot +Suite Setup Open Browser To Start Page +Suite Teardown Close All Browsers diff --git a/test/acceptance/keywords/async_javascript.robot b/test/acceptance/keywords/async_javascript.robot index 45e54774d..41aba919f 100644 --- a/test/acceptance/keywords/async_javascript.robot +++ b/test/acceptance/keywords/async_javascript.robot @@ -1,92 +1,109 @@ *** Settings *** -Test Setup Go To Page "javascript/dynamic_content.html" -Suite Teardown Set Selenium Timeout 5 seconds -Resource ../resource.robot +Documentation Tests asynchronous javascript +Suite Teardown Set Selenium Timeout 5 seconds +Test Setup Go To Page "javascript/dynamic_content.html" +Resource ../resource.robot *** Test Cases *** Should Not Timeout If Callback Invoked Immediately - ${result} = Execute Async Javascript arguments[arguments.length - 1](123); - Should Be Equal ${result} ${123} + [Documentation] Should Not Timeout If Callback Invoked Immediately + ${result} = Execute Async Javascript arguments[arguments.length - 1](123); + Should Be Equal ${result} ${123} Should Be Able To Return Javascript Primitives From Async Scripts Neither None Nor Undefined - ${result} = Execute Async Javascript arguments[arguments.length - 1](123); - Should Be Equal ${result} ${123} - ${result} = Execute Async Javascript arguments[arguments.length - 1]('abc'); - Should Be Equal ${result} abc - ${result} = Execute Async Javascript arguments[arguments.length - 1](false); - Should Be Equal ${result} ${false} - ${result} = Execute Async Javascript arguments[arguments.length - 1](true); - Should Be Equal ${result} ${true} + [Documentation] Should Be Able To Return Javascript Primitives From Async Scripts + ... Neither None Nor Undefined + ${result} = Execute Async Javascript arguments[arguments.length - 1](123); + Should Be Equal ${result} ${123} + ${result} = Execute Async Javascript arguments[arguments.length - 1]('abc'); + Should Be Equal ${result} abc + ${result} = Execute Async Javascript arguments[arguments.length - 1](false); + Should Be Equal ${result} ${false} + ${result} = Execute Async Javascript arguments[arguments.length - 1](true); + Should Be Equal ${result} ${true} Should Be Able To Return Javascript Primitives From Async Scripts Null And Undefined - ${result} = Execute Async Javascript arguments[arguments.length - 1](null); - Should Be Equal ${result} ${None} - ${result} = Execute Async Javascript arguments[arguments.length - 1](); - Should Be Equal ${result} ${None} + [Documentation] Should Be Able To Return Javascript Primitives From Async Scripts + ... Null And Undefined + ${result} = Execute Async Javascript arguments[arguments.length - 1](null); + Should Be Equal ${result} ${None} + ${result} = Execute Async Javascript arguments[arguments.length - 1](); + Should Be Equal ${result} ${None} Should Be Able To Return An Array Literal From An Async Script - ${result} = Execute Async Javascript arguments[arguments.length - 1]([]); - Should Not Be Equal ${result} ${None} - Length Should Be ${result} 0 + [Documentation] Should Be Able To Return An Array Literal From An Async Script + ${result} = Execute Async Javascript arguments[arguments.length - 1]([]); + Should Not Be Equal ${result} ${None} + Length Should Be ${result} 0 Should Be Able To Return An Array Object From An Async Script - ${result} = Execute Async Javascript arguments[arguments.length - 1](new Array()); - Should Not Be Equal ${result} ${None} - Length Should Be ${result} 0 + [Documentation] Should Be Able To Return An Array Object From An Async Script + ${result} = Execute Async Javascript arguments[arguments.length - 1](new Array()); + Should Not Be Equal ${result} ${None} + Length Should Be ${result} 0 Should Be Able To Return Arrays Of Primitives From Async Scripts - ${result} = Execute Async Javascript arguments[arguments.length - 1]([null, 123, 'abc', true, false]); - Should Not Be Equal ${result} ${None} - Length Should Be ${result} 5 - ${value} = Remove From List ${result} -1 - Should Be Equal ${value} ${false} - ${value} = Remove From List ${result} -1 - Should Be Equal ${value} ${true} - ${value} = Remove From List ${result} -1 - Should Be Equal ${value} abc - ${value} = Remove From List ${result} -1 - Should Be Equal ${value} ${123} - ${value} = Remove From List ${result} -1 - Should Be Equal ${value} ${None} - Length Should Be ${result} 0 + [Documentation] Should Be Able To Return Arrays Of Primitives From Async Scripts + ${result} = Execute Async Javascript + ... arguments[arguments.length - 1]([null, 123, 'abc', true, false]); + Should Not Be Equal ${result} ${None} + Length Should Be ${result} 5 + ${value} = Remove From List ${result} -1 + Should Be Equal ${value} ${false} + ${value} = Remove From List ${result} -1 + Should Be Equal ${value} ${true} + ${value} = Remove From List ${result} -1 + Should Be Equal ${value} abc + ${value} = Remove From List ${result} -1 + Should Be Equal ${value} ${123} + ${value} = Remove From List ${result} -1 + Should Be Equal ${value} ${None} + Length Should Be ${result} 0 Should Timeout If Script Does Not Invoke Callback + [Documentation] Should Timeout If Script Does Not Invoke Callback Run Keyword And Expect Error - ... TimeoutException: Message: Timed out waiting for async script result after * - ... Execute Async Javascript return 1 + 2; + ... TimeoutException: Message: Timed out waiting for async script result after * + ... Execute Async Javascript return 1 + 2; Should Timeout If Script Does Not Invoke Callback With A Zero Timeout + [Documentation] Should Timeout If Script Does Not Invoke Callback With A Zero Timeout Run Keyword And Expect Error - ... TimeoutException: Message: Timed out waiting for async script result after * - ... Execute Async Javascript window.setTimeout(function() {}, 0); + ... TimeoutException: Message: Timed out waiting for async script result after * + ... Execute Async Javascript window.setTimeout(function() {}, 0); Should Not Timeout If Script Callsback Inside A Zero Timeout - ${result} = Execute Async Javascript - ... var callback = arguments[arguments.length - 1]; - ... window.setTimeout(function() { callback(123); }, 0) + [Documentation] Should Not Timeout If Script Callsback Inside A Zero Timeout + ${result} = Execute Async Javascript + ... var callback = arguments[arguments.length - 1]; + ... window.setTimeout(function() { callback(123); }, 0) Should Timeout If Script Does Not Invoke Callback With Long Timeout - Set Selenium Timeout 0.5 seconds + [Documentation] Should Timeout If Script Does Not Invoke Callback With Long Timeout + Set Selenium Timeout 0.5 seconds Run Keyword And Expect Error - ... TimeoutException: Message: Timed out waiting for async script result after * - ... Execute Async Javascript var callback = arguments[arguments.length - 1]; window.setTimeout(callback, 1500); + ... TimeoutException: Message: Timed out waiting for async script result after * + ... Execute Async Javascript + ... var callback = arguments[arguments.length - 1]; + ... window.setTimeout(callback, 1500); Should Detect Page Loads While Waiting On An Async Script And Return An Error - Set Selenium Timeout 0.1 seconds + [Documentation] Should Detect Page Loads While Waiting On An Async Script + ... And Return An Error + Set Selenium Timeout 0.1 seconds Run Keyword And Expect Error - ... WebDriverException: Message: Detected a page unload event; async script execution does not work across page loads* - ... Execute Async Javascript window.location = 'javascript/dynamic'; + ... WebDriverException: Message: Detected a page unload event; async script execution does not work across page loads* + ... Execute Async Javascript window.location = 'javascript/dynamic'; Should Catch Errors When Executing Initial Script - Run Keyword And Expect Error - ... WebDriverException: Message: you should catch this!* - ... Execute Async Javascript throw Error('you should catch this!'); - -#TODO Implement Selenium asynchronous javascript test -#Should Be Able To Execute Asynchronous Scripts -# # To Do - -#TODO EdManlove Add support for arguement passing to selenium javascript calls -#Should Be Able To Pass Multiple Arguments To Async Scripts -# ${result} = Execute Async Javascript arguments[arguments.length - 1](arguments[0] + arguments[1]); 1 2 -# Should Be Equal ${result} ${3} + [Documentation] Should Catch Errors When Executing Initial Script + Run Keyword And Expect Error WebDriverException: Message: you should catch this!* + ... Execute Async Javascript throw Error('you should catch this!'); + #TODO Implement Selenium asynchronous javascript test + #Should Be Able To Execute Asynchronous Scripts + # # To Do + #TODO EdManlove Add support for arguement passing to selenium javascript calls + #Should Be Able To Pass Multiple Arguments To Async Scripts + # ${result} = Execute Async Javascript + #... arguments[arguments.length - 1](arguments[0] + arguments[1]); 1 2 + # Should Be Equal ${result} ${3} diff --git a/test/acceptance/keywords/checkbox_and_radio_buttons.robot b/test/acceptance/keywords/checkbox_and_radio_buttons.robot index 6acb63ffc..770e694b2 100644 --- a/test/acceptance/keywords/checkbox_and_radio_buttons.robot +++ b/test/acceptance/keywords/checkbox_and_radio_buttons.robot @@ -1,51 +1,58 @@ *** Settings *** -Test Setup Go To Page "forms/prefilled_email_form.html" -Resource ../resource.robot +Documentation Test checkboxes and radio buttons +Test Setup Go To Page "forms/prefilled_email_form.html" +Resource ../resource.robot *** Test Cases *** Checkbox Should Be Selected - [Documentation] LOG 2 Verifying checkbox 'can_send_email' is selected. - Checkbox Should Be Selected can_send_email - Run Keyword And Expect Error Checkbox 'can_send_sms' should have been selected but was not Checkbox Should Be Selected can_send_sms + [Documentation] LOG 2 Verifying checkbox 'can_send_email' is selected. + Checkbox Should Be Selected can_send_email + Run Keyword And Expect Error Checkbox 'can_send_sms' should have been selected but was not + ... Checkbox Should Be Selected can_send_sms Checkbox Should Not Be Selected - [Documentation] LOG 2 Verifying checkbox 'can_send_sms' is not selected. - Checkbox Should Not Be Selected can_send_sms - Run Keyword And Expect Error Checkbox 'can_send_email' should not have been selected Checkbox Should Not Be Selected can_send_email + [Documentation] LOG 2 Verifying checkbox 'can_send_sms' is not selected. + Checkbox Should Not Be Selected can_send_sms + Run Keyword And Expect Error Checkbox 'can_send_email' should not have been selected + ... Checkbox Should Not Be Selected can_send_email Select Checkbox - [Documentation] LOG 2 Selecting checkbox 'can_send_sms'. - Select Checkbox can_send_sms - Checkbox Should Be Selected can_send_sms - Select Checkbox can_send_sms - Checkbox Should Be Selected can_send_sms + [Documentation] LOG 2 Selecting checkbox 'can_send_sms'. + Select Checkbox can_send_sms + Checkbox Should Be Selected can_send_sms + Select Checkbox can_send_sms + Checkbox Should Be Selected can_send_sms UnSelect Checkbox - [Documentation] LOG 2 Unselecting checkbox 'can_send_email'. - Unselect Checkbox can_send_email - Checkbox Should Not Be Selected can_send_email - Unselect Checkbox can_send_email - Checkbox Should Not Be Selected can_send_email + [Documentation] LOG 2 Unselecting checkbox 'can_send_email'. + Unselect Checkbox can_send_email + Checkbox Should Not Be Selected can_send_email + Unselect Checkbox can_send_email + Checkbox Should Not Be Selected can_send_email Radio Button Should Be Set To - [Documentation] LOG 2 Verifying radio button 'sex' has selection 'female'. - Radio Button Should Be Set To sex female - Run Keyword And Expect Error Selection of radio button 'sex' should have been 'male' but was 'female' Radio Button Should Be Set To sex male + [Documentation] LOG 2 Verifying radio button 'sex' has selection 'female'. + Radio Button Should Be Set To sex female + Run Keyword And Expect Error + ... Selection of radio button 'sex' should have been 'male' but was 'female' + ... Radio Button Should Be Set To sex male Select Radio Button - [Documentation] LOG 2 Selecting 'male' from radio button 'sex'. - Select Radio Button sex male - Radio Button Should Be Set To sex male - Select Radio Button sex female - Radio Button Should Be Set To sex female + [Documentation] LOG 2 Selecting 'male' from radio button 'sex'. + Select Radio Button sex male + Radio Button Should Be Set To sex male + Select Radio Button sex female + Radio Button Should Be Set To sex female Radio Button Should Not Be Selected - [Documentation] LOG 2 Verifying radio button 'referrer' has no selection. - Radio Button Should Not Be Selected referrer - Run Keyword And Expect Error Radio button group 'sex' should not have had selection, but 'female' was selected Radio Button Should Not Be Selected sex + [Documentation] LOG 2 Verifying radio button 'referrer' has no selection. + Radio Button Should Not Be Selected referrer + Run Keyword And Expect Error + ... Radio button group 'sex' should not have had selection, but 'female' was selected + ... Radio Button Should Not Be Selected sex Clicking Radio Button Should Trigger Onclick Event - [Setup] Go To Page "javascript/dynamic_content.html" - Select Radio Button group title - Title Should Be Changed by Button - + [Documentation] Clicking Radio Button Should Trigger Onclick Event + [Setup] Go To Page "javascript/dynamic_content.html" + Select Radio Button group title + Title Should Be Changed by Button diff --git a/test/acceptance/keywords/click_element.robot b/test/acceptance/keywords/click_element.robot index 4c446da17..c820b14a0 100644 --- a/test/acceptance/keywords/click_element.robot +++ b/test/acceptance/keywords/click_element.robot @@ -1,21 +1,23 @@ *** Settings *** -Suite Setup Go To Page "javascript/click.html" -Test Setup Initialize Page -Resource ../resource.robot +Documentation Tests clicking element +Suite Setup Go To Page "javascript/click.html" +Test Setup Initialize Page +Resource ../resource.robot *** Test Cases *** Click Element - [Documentation] LOG 2 Clicking element 'singleClickButton'. - Click Element singleClickButton - Element Text Should Be output single clicked + [Documentation] LOG 2 Clicking element 'singleClickButton'. + Click Element singleClickButton + Element Text Should Be output single clicked Double Click Element - [Documentation] LOG 2 Double clicking element 'doubleClickButton'. - [Tags] Known Issue - Firefox - Double Click Element doubleClickButton - Element Text Should Be output double clicked + [Documentation] LOG 2 Double clicking element 'doubleClickButton'. + [Tags] Known Issue - Firefox + Double Click Element doubleClickButton + Element Text Should Be output double clicked *** Keywords *** Initialize Page + [Documentation] Initialize Page Reload Page - Element Text Should Be output initial output + Element Text Should Be output initial output diff --git a/test/acceptance/keywords/click_element_at_coordinates.robot b/test/acceptance/keywords/click_element_at_coordinates.robot index 902f4584c..32e08a602 100644 --- a/test/acceptance/keywords/click_element_at_coordinates.robot +++ b/test/acceptance/keywords/click_element_at_coordinates.robot @@ -1,4 +1,5 @@ *** Settings *** +Documentation Clicks element at coordinates Suite Setup Go To Page "javascript/click_at_coordinates.html" Test Setup Initialize Page Resource ../resource.robot @@ -7,12 +8,13 @@ Resource ../resource.robot Click Element At Coordinates [Documentation] LOG 2 Click clicking element 'Clickable' in coordinates '10', '20'. [Tags] Known Issue - Firefox - Click Element At Coordinates Clickable ${10} ${20} + Click Element At Coordinates Clickable ${10} ${20} Element Text Should Be outputX 110 Element Text Should Be outputY 120 *** Keywords *** Initialize page + [Documentation] Initialize page Reload Page Element Text Should Be outputX initial outputX Element Text Should Be outputY initial outputY diff --git a/test/acceptance/keywords/content_assertions.robot b/test/acceptance/keywords/content_assertions.robot index 392ddc49b..a27d3c345 100644 --- a/test/acceptance/keywords/content_assertions.robot +++ b/test/acceptance/keywords/content_assertions.robot @@ -1,250 +1,330 @@ *** Settings *** -Test Setup Go To Front Page -Default Tags assertions -Resource ../resource.robot - +Documentation Tests contents +Test Setup Go To Front Page +Default Tags assertions +Resource ../resource.robot *** Test Cases *** Location Should Be - [Documentation] LOG 2:3 Current location is '${FRONT PAGE}'. - Location Should Be ${FRONT PAGE} - Run Keyword And Expect Error Location should have been 'non existing' but was '${FRONT PAGE}' Location Should Be non existing + [Documentation] LOG 2:3 Current location is '${FRONT PAGE}'. + Location Should Be ${FRONT PAGE} + Run Keyword And Expect Error Location should have been 'non existing' but was '${FRONT PAGE}' + ... Location Should Be non existing Location Should Contain - [Documentation] LOG 2:3 Current location contains 'html'. - Location Should Contain html - Run Keyword And Expect Error Location should have contained 'not a location' but it was '${FRONT PAGE}'. Location Should Contain not a location + [Documentation] LOG 2:3 Current location contains 'html'. + Location Should Contain html + Run Keyword And Expect Error + ... Location should have contained 'not a location' but it was '${FRONT PAGE}'. + ... Location Should Contain not a location Title Should Be - [Documentation] LOG 2:3 Page title is '(root)/index.html'. - Title Should Be (root)/index.html - Run Keyword And Expect Error Title should have been 'not a title' but was '(root)/index.html' Title Should Be not a title + [Documentation] LOG 2:3 Page title is '(root)/index.html'. + Title Should Be (root)/index.html + Run Keyword And Expect Error Title should have been 'not a title' but was '(root)/index.html' + ... Title Should Be not a title Page Should Contain - [Documentation] LOG 2:5 Current page contains text 'needle'. LOG 4.1:10 REGEXP: (?i) - Page Should Contain needle - Page Should Contain This is the haystack - Run Keyword And Expect Error Page should have contained text 'non existing text' but did not Page Should Contain non existing text + [Documentation] LOG 2:5 Current page contains text 'needle'. + ... LOG 4.1:10 REGEXP: (?i) + Page Should Contain needle + Page Should Contain This is the haystack + Run Keyword And Expect Error Page should have contained text 'non existing text' but did not + ... Page Should Contain non existing text Page Should Contain With Custom Log Level - [Documentation] LOG 2.1:10 DEBUG REGEXP: (?i) - Run Keyword And Expect Error Page should have contained text 'non existing text' but did not Page Should Contain non existing text DEBUG + [Documentation] LOG 2.1:10 DEBUG REGEXP: (?i) + Run Keyword And Expect Error Page should have contained text 'non existing text' but did not + ... Page Should Contain non existing text DEBUG Page Should Contain With Disabling Source Logging - [Documentation] LOG 3:2 NONE - Set Log Level INFO - Run Keyword And Expect Error Page should have contained text 'non existing text' but did not Page Should Contain non existing text loglevel=NONE - [Teardown] Set Log Level DEBUG + [Documentation] LOG 3:2 NONE + Set Log Level INFO + Run Keyword And Expect Error Page should have contained text 'non existing text' but did not + ... Page Should Contain non existing text loglevel=NONE + [Teardown] Set Log Level DEBUG Page Should Contain With Frames - [Setup] Go To Page "frames/frameset.html" - Page Should Contain You're looking at right. + [Documentation] Page Should Contain With Frames + [Setup] Go To Page "frames/frameset.html" + Page Should Contain You're looking at right. Page Should Not Contain - [Documentation] LOG 2:8 Current page does not contain text 'non existing text'. LOG 3.1:7 REGEXP: (?i) - Page Should Not Contain non existing text - Run Keyword And Expect Error Page should not have contained text 'needle' Page Should Not Contain needle + [Documentation] LOG 2:8 Current page does not contain text 'non existing text'. + ... LOG 3.1:7 REGEXP: (?i) + Page Should Not Contain non existing text + Run Keyword And Expect Error Page should not have contained text 'needle' + ... Page Should Not Contain needle Page Should Not Contain With Custom Log Level - [Documentation] LOG 2.1:7 DEBUG REGEXP: (?i) - Run Keyword And Expect Error Page should not have contained text 'needle' Page Should Not Contain needle DEBUG + [Documentation] LOG 2.1:7 DEBUG REGEXP: (?i) + Run Keyword And Expect Error Page should not have contained text 'needle' + ... Page Should Not Contain needle DEBUG Page Should Not Contain With Disabling Source Logging - [Documentation] LOG 3:2 NONE - Set Log Level INFO - Run Keyword And Expect Error Page should not have contained text 'needle' Page Should Not Contain needle loglevel=NONE - [Teardown] Set Log Level DEBUG + [Documentation] LOG 3:2 NONE + Set Log Level INFO + Run Keyword And Expect Error Page should not have contained text 'needle' + ... Page Should Not Contain needle loglevel=NONE + [Teardown] Set Log Level DEBUG Page Should Contain Element - Page Should Contain Element some_id - Run Keyword And Expect Error Page should have contained element 'non-existent' but did not Page Should Contain Element non-existent + [Documentation] Page Should Contain Element + Page Should Contain Element some_id + Run Keyword And Expect Error Page should have contained element 'non-existent' but did not + ... Page Should Contain Element non-existent Page Should Contain Element With Custom Message - Run Keyword And Expect Error Custom error message Page Should Contain Element invalid Custom error message + [Documentation] Page Should Contain Element With Custom Message + Run Keyword And Expect Error Custom error message Page Should Contain Element + ... invalid Custom error message Page Should Contain Element With Disabling Source Logging - [Documentation] LOG 3:2 NONE - Set Log Level INFO - Run Keyword And Expect Error Page should have contained element 'non-existent' but did not Page Should Contain Element non-existent loglevel=NONE - [Teardown] Set Log Level DEBUG + [Documentation] LOG 3:2 NONE + Set Log Level INFO + Run Keyword And Expect Error Page should have contained element 'non-existent' but did not + ... Page Should Contain Element non-existent loglevel=NONE + [Teardown] Set Log Level DEBUG Page Should Not Contain Element - Page Should Not Contain Element non-existent - Run Keyword And Expect Error Page should not have contained element 'some_id' Page Should Not Contain Element some_id + [Documentation] Page Should Not Contain Element + Page Should Not Contain Element non-existent + Run Keyword And Expect Error Page should not have contained element 'some_id' + ... Page Should Not Contain Element some_id Page Should Not Contain Element With Disabling Source Logging - [Documentation] LOG 3:2 NONE - Set Log Level INFO - Run Keyword And Expect Error Page should not have contained element 'some_id' Page Should Not Contain Element some_id loglevel=NONE - [Teardown] Set Log Level DEBUG + [Documentation] LOG 3:2 NONE + Set Log Level INFO + Run Keyword And Expect Error Page should not have contained element 'some_id' + ... Page Should Not Contain Element some_id loglevel=NONE + [Teardown] Set Log Level DEBUG Element Should Contain - Element Should Contain some_id This text is inside an identified element - Run Keyword And Expect Error Element 'some_id' should have contained text 'non existing text' but its text was 'This text is inside an identified element'. Element Should Contain some_id non existing text - Run Keyword And Expect Error ValueError: Element locator 'missing_id' did not match any elements. Element Should Contain missing_id This should report missing element. + [Documentation] Element Should Contain + Element Should Contain some_id This text is inside an identified element + Run Keyword And Expect Error + ... Element 'some_id' should have contained text 'non existing text' but its text was 'This text is inside an identified element'. + ... Element Should Contain some_id non existing text + Run Keyword And Expect Error + ... ValueError: Element locator 'missing_id' did not match any elements. + ... Element Should Contain missing_id This should report missing element. Element Should Not Contain - Element Should Not Contain some_id This text is not inside an identified element - Element Should Not Contain some_id elementypo - Run Keyword And Expect Error Element 'some_id' should not contain text 'This text is inside an identified element' but it did. Element Should Not Contain some_id This text is inside an identified element - Run Keyword And Expect Error ValueError: Element locator 'missing_id' did not match any elements. Element Should Not Contain missing_id This should report missing element. + [Documentation] Element Should Not Contain + Element Should Not Contain some_id This text is not inside an identified element + Element Should Not Contain some_id elementypo + Run Keyword And Expect Error + ... Element 'some_id' should not contain text 'This text is inside an identified element' but it did. + ... Element Should Not Contain some_id This text is inside an identified element + Run Keyword And Expect Error + ... ValueError: Element locator 'missing_id' did not match any elements. + ... Element Should Not Contain missing_id This should report missing element. Element Text Should Be - Element Text Should Be some_id This text is inside an identified element - Run Keyword And Expect Error The text of element 'some_id' should have been 'inside' but in fact it was 'This text is inside an identified element'. Element Text Should Be some_id inside + [Documentation] Element Text Should Be + Element Text Should Be some_id This text is inside an identified element + Run Keyword And Expect Error + ... The text of element 'some_id' should have been 'inside' but in fact it was 'This text is inside an identified element'. + ... Element Text Should Be some_id inside Get Text - ${str} = Get Text some_id - Should Match ${str} This text is inside an identified element - Run Keyword And Expect Error ValueError: Element locator 'missing_id' did not match any elements. Get Text missing_id + [Documentation] Get Text + ${str} = Get Text some_id + Should Match ${str} This text is inside an identified element + Run Keyword And Expect Error + ... ValueError: Element locator 'missing_id' did not match any elements. + ... Get Text missing_id Element Should Be Visible - [Setup] Go To Page "visibility.html" - Element Should Be Visible i_am_visible - Run Keyword And Expect Error The element 'i_am_hidden' should be visible, but it is not. Element Should Be Visible i_am_hidden + [Documentation] Element Should Be Visible + [Setup] Go To Page "visibility.html" + Element Should Be Visible i_am_visible + Run Keyword And Expect Error The element 'i_am_hidden' should be visible, but it is not. + ... Element Should Be Visible i_am_hidden Element Should Not Be Visible - [Setup] Go To Page "visibility.html" - Element Should Not Be Visible i_am_hidden - Run Keyword And Expect Error The element 'i_am_visible' should not be visible, but it is. Element Should Not Be Visible i_am_visible + [Documentation] Element Should Not Be Visible + [Setup] Go To Page "visibility.html" + Element Should Not Be Visible i_am_hidden + Run Keyword And Expect Error The element 'i_am_visible' should not be visible, but it is. + ... Element Should Not Be Visible i_am_visible Page Should Contain Checkbox - [Documentation] LOG 2:5 Current page contains checkbox 'can_send_email'. - [Setup] Go To Page "forms/prefilled_email_form.html" - Page Should Contain Checkbox can_send_email - Page Should Contain Checkbox xpath=//input[@type='checkbox' and @name='can_send_sms'] - Run Keyword And Expect Error Page should have contained checkbox 'non-existing' but did not Page Should Contain Checkbox non-existing + [Documentation] LOG 2:5 Current page contains checkbox 'can_send_email'. + [Setup] Go To Page "forms/prefilled_email_form.html" + Page Should Contain Checkbox can_send_email + Page Should Contain Checkbox xpath=//input[@type='checkbox' and @name='can_send_sms'] + Run Keyword And Expect Error Page should have contained checkbox 'non-existing' but did not + ... Page Should Contain Checkbox non-existing Page Should Not Contain Checkbox - [Documentation] LOG 2:5 Current page does not contain checkbox 'non-existing'. - [Setup] Go To Page "forms/prefilled_email_form.html" - Page Should Not Contain Checkbox non-existing - Run Keyword And Expect Error Page should not have contained checkbox 'can_send_email' Page Should Not Contain Checkbox can_send_email + [Documentation] LOG 2:5 Current page does not contain checkbox 'non-existing'. + [Setup] Go To Page "forms/prefilled_email_form.html" + Page Should Not Contain Checkbox non-existing + Run Keyword And Expect Error Page should not have contained checkbox 'can_send_email' + ... Page Should Not Contain Checkbox can_send_email Page Should Contain Radio Button - [Setup] Go To Page "forms/prefilled_email_form.html" - Page Should Contain Radio Button sex - Page Should Contain Radio Button xpath=//input[@type="radio" and @value="male"] - Run Keyword And Expect Error Page should have contained radio button 'non-existing' but did not Page Should Contain Radio Button non-existing + [Documentation] Page Should Contain Radio Button + [Setup] Go To Page "forms/prefilled_email_form.html" + Page Should Contain Radio Button sex + Page Should Contain Radio Button xpath=//input[@type="radio" and @value="male"] + Run Keyword And Expect Error Page should have contained radio button 'non-existing' but did not + ... Page Should Contain Radio Button non-existing Page Should Not Contain Radio Button - [Setup] Go To Page "forms/prefilled_email_form.html" - Page Should Not Contain Radio Button non-existing - Run Keyword And Expect Error Page should not have contained radio button 'sex' Page Should Not Contain Radio Button sex + [Documentation] Page Should Not Contain Radio Button + [Setup] Go To Page "forms/prefilled_email_form.html" + Page Should Not Contain Radio Button non-existing + Run Keyword And Expect Error Page should not have contained radio button 'sex' + ... Page Should Not Contain Radio Button sex Page Should Contain Image - [Setup] Go To Page "links.html" - Page Should contain Image image.jpg - Run Keyword And Expect Error Page should have contained image 'non-existent' but did not Page Should contain Image non-existent + [Documentation] Page Should Contain Image + [Setup] Go To Page "links.html" + Page Should contain Image image.jpg + Run Keyword And Expect Error Page should have contained image 'non-existent' but did not + ... Page Should contain Image non-existent Page Should Not Contain Image - [Setup] Go To Page "links.html" - Page Should not contain Image non-existent - Run Keyword And Expect Error Page should not have contained image 'image.jpg' Page Should not contain Image image.jpg + [Documentation] Page Should Not Contain Image + [Setup] Go To Page "links.html" + Page Should not contain Image non-existent + Run Keyword And Expect Error Page should not have contained image 'image.jpg' + ... Page Should not contain Image image.jpg Page Should Contain Link - [Setup] Go To Page "links.html" - Page Should contain link Relative - Page Should contain link sub/index.html - Run Keyword And Expect Error Page should have contained link 'non-existent' but did not Page Should contain link non-existent + [Documentation] Page Should Contain Link + [Setup] Go To Page "links.html" + Page Should contain link Relative + Page Should contain link sub/index.html + Run Keyword And Expect Error Page should have contained link 'non-existent' but did not + ... Page Should contain link non-existent Page Should Not Contain Link - [Setup] Go To Page "links.html" - Page Should not contain link non-existent - Run Keyword And Expect Error Page should not have contained link 'Relative' Page Should not contain link Relative + [Documentation] Page Should Not Contain Link + [Setup] Go To Page "links.html" + Page Should not contain link non-existent + Run Keyword And Expect Error Page should not have contained link 'Relative' + ... Page Should not contain link Relative Page Should Contain List - [Setup] Go To Page "forms/prefilled_email_form.html" - Page should Contain List possible_channels - Run Keyword And Expect Error Page should have contained list 'non-existing' but did not Page Should Contain List non-existing + [Documentation] Page Should Contain List + [Setup] Go To Page "forms/prefilled_email_form.html" + Page should Contain List possible_channels + Run Keyword And Expect Error Page should have contained list 'non-existing' but did not + ... Page Should Contain List non-existing Page Should Not Contain List - [Setup] Go To Page "forms/prefilled_email_form.html" - Page Should Not Contain List non-existing - Run Keyword And Expect Error Page should not have contained list 'possible_channels' Page Should Not Contain List possible_channels + [Documentation] Page Should Not Contain List + [Setup] Go To Page "forms/prefilled_email_form.html" + Page Should Not Contain List non-existing + Run Keyword And Expect Error Page should not have contained list 'possible_channels' + ... Page Should Not Contain List possible_channels Page Should Contain TextField - [Setup] Go To Page "forms/prefilled_email_form.html" - Page Should Contain Text Field name - Page Should Contain Text Field xpath=//input[@type='text' and @name='email'] - Run Keyword And Expect Error Page should have contained text field 'non-existing' but did not Page Should Contain Text Field non-existing + [Documentation] Page Should Contain TextField + [Setup] Go To Page "forms/prefilled_email_form.html" + Page Should Contain Text Field name + Page Should Contain Text Field xpath=//input[@type='text' and @name='email'] + Run Keyword And Expect Error Page should have contained text field 'non-existing' but did not + ... Page Should Contain Text Field non-existing Page Should Not Contain Text Field - [Setup] Go To Page "forms/prefilled_email_form.html" - Page Should Not Contain Text Field non-existing - Run Keyword And Expect Error Page should not have contained text field 'name' Page Should Not Contain Text Field name + [Documentation] Page Should Not Contain Text Field + [Setup] Go To Page "forms/prefilled_email_form.html" + Page Should Not Contain Text Field non-existing + Run Keyword And Expect Error Page should not have contained text field 'name' + ... Page Should Not Contain Text Field name TextField Should Contain - [Documentation] LOG 2:7 Text field 'name' contains text ''. - [Setup] Go To Page "forms/email_form.html" - TextField Should contain name ${EMPTY} - Input Text name my name - TextField Should contain name my name - Run Keyword And Expect Error Text field 'name' should have contained text 'non-existing' but it contained 'my name' TextField Should contain name non-existing + [Documentation] LOG 2:7 Text field 'name' contains text ''. + [Setup] Go To Page "forms/email_form.html" + TextField Should contain name ${EMPTY} + Input Text name my name + TextField Should contain name my name + Run Keyword And Expect Error + ... Text field 'name' should have contained text 'non-existing' but it contained 'my name' + ... TextField Should contain name non-existing TextField Value Should Be - [Documentation] LOG 2:7 Content of text field 'name' is ''. - [Setup] Go To Page "forms/email_form.html" - textfield Value Should Be name ${EMPTY} - Input Text name my name - textfield Value Should Be name my name - Run Keyword And Expect Error Value of text field 'name' should have been 'non-existing' but was 'my name' textfield Value Should Be name non-existing - Clear Element Text name - Textfield Value Should Be name ${EMPTY} + [Documentation] LOG 2:7 Content of text field 'name' is ''. + [Setup] Go To Page "forms/email_form.html" + textfield Value Should Be name ${EMPTY} + Input Text name my name + textfield Value Should Be name my name + Run Keyword And Expect Error + ... Value of text field 'name' should have been 'non-existing' but was 'my name' + ... textfield Value Should Be name non-existing + Clear Element Text name + Textfield Value Should Be name ${EMPTY} TextArea Should Contain - [Setup] Go To Page "forms/email_form.html" - TextArea Should Contain comment ${EMPTY} - Input Text comment This is a comment. + [Documentation] TextArea Should Contain + [Setup] Go To Page "forms/email_form.html" + TextArea Should Contain comment ${EMPTY} + Input Text comment This is a comment. Run Keyword And Expect Error - ... Text field 'comment' should have contained text 'Hello World!' but it contained 'This is a comment.' - ... TextArea Should Contain comment Hello World! + ... Text field 'comment' should have contained text 'Hello World!' but it contained 'This is a comment.' + ... TextArea Should Contain comment Hello World! TextArea Value Should Be - [Setup] Go To Page "forms/email_form.html" - TextArea Value Should Be comment ${EMPTY} - Input Text comment This is a comment. + [Documentation] TextArea Value Should Be + [Setup] Go To Page "forms/email_form.html" + TextArea Value Should Be comment ${EMPTY} + Input Text comment This is a comment. Run Keyword And Expect Error - ... Text field 'comment' should have contained text 'Hello World!' but it contained 'This is a comment.' - ... TextArea Value Should Be comment Hello World! - Clear Element Text comment - TextArea Value Should Be comment ${EMPTY} + ... Text field 'comment' should have contained text 'Hello World!' but it contained 'This is a comment.' + ... TextArea Value Should Be comment Hello World! + Clear Element Text comment + TextArea Value Should Be comment ${EMPTY} Page Should Contain Button - [Setup] Go To Page "forms/buttons.html" - Page Should Contain Button button - Page Should Contain Button Sisään - Page Should Contain Button Get In - Page Should Contain Button xpath=//button[@type="submit"] - Page Should Contain Button Ulos - Page Should Contain Button xpath=//input[@type="submit"] - Page Should Contain Button Act! - Page Should Contain Button xpath=//input[@type="button"] - Run Keyword And Expect Error Page should have contained button 'non-existing' but did not Page Should Contain Button non-existing + [Documentation] Page Should Contain Button + [Setup] Go To Page "forms/buttons.html" + Page Should Contain Button button + Page Should Contain Button Sisään + Page Should Contain Button Get In + Page Should Contain Button xpath=//button[@type="submit"] + Page Should Contain Button Ulos + Page Should Contain Button xpath=//input[@type="submit"] + Page Should Contain Button Act! + Page Should Contain Button xpath=//input[@type="button"] + Run Keyword And Expect Error Page should have contained button 'non-existing' but did not + ... Page Should Contain Button non-existing Page Should Not Contain Button In Button Tag - [Setup] Go To Page "forms/buttons.html" - Page Should Not Contain Button invalid - Run Keyword And Expect Error Page should not have contained button 'button' Page Should Not Contain Button button + [Documentation] Page Should Not Contain Button In Button Tag + [Setup] Go To Page "forms/buttons.html" + Page Should Not Contain Button invalid + Run Keyword And Expect Error Page should not have contained button 'button' + ... Page Should Not Contain Button button Page Should Not Contain Button In Input Tag - [Setup] Go To Page "forms/buttons.html" - Page Should Not Contain Button invalid - Run Keyword And Expect Error Page should not have contained input 'Act!' Page Should Not Contain Button Act! + [Documentation] Page Should Not Contain Button In Input Tag + [Setup] Go To Page "forms/buttons.html" + Page Should Not Contain Button invalid + Run Keyword And Expect Error Page should not have contained input 'Act!' + ... Page Should Not Contain Button Act! Get All Links - [Setup] Go To Page "links.html" - ${links}= Get All Links - Length Should Be ${links} 19 - List Should Contain Value ${links} bold_id + [Documentation] Get All Links + [Setup] Go To Page "links.html" + ${links}= Get All Links + Length Should Be ${links} 19 + List Should Contain Value ${links} bold_id Xpath Should Match X Times - [Setup] Go To Page "forms/login.html" - Xpath Should Match X Times //input[@type="text"] 1 - Xpath Should Match X Times //input[@type="text"] ${1} - Run Keyword And Expect Error Xpath //input[@type="text"] should have matched 2 times but matched 1 times Xpath Should Match X Times //input[@type="text"] 2 + [Documentation] Xpath Should Match X Times + [Setup] Go To Page "forms/login.html" + Xpath Should Match X Times //input[@type="text"] 1 + Xpath Should Match X Times //input[@type="text"] ${1} + Run Keyword And Expect Error + ... Xpath //input[@type="text"] should have matched 2 times but matched 1 times + ... Xpath Should Match X Times //input[@type="text"] 2 Locator Should Match X Times - [Setup] Go To Page "links.html" - Locator Should Match X Times link=Link 2 - Locator Should Match X Times link=Missing Link 0 + [Documentation] Locator Should Match X Times + [Setup] Go To Page "links.html" + Locator Should Match X Times link=Link 2 + Locator Should Match X Times link=Missing Link 0 diff --git a/test/acceptance/keywords/cookies.robot b/test/acceptance/keywords/cookies.robot index e39a64b4c..902d46fde 100644 --- a/test/acceptance/keywords/cookies.robot +++ b/test/acceptance/keywords/cookies.robot @@ -1,4 +1,5 @@ *** Setting *** +Documentation Tests cookies Suite Setup Go To Page "cookies.html" Suite Teardown Delete All Cookies Test Setup Add Cookies @@ -6,38 +7,48 @@ Resource ../resource.robot *** Test Cases *** Get Cookies + [Documentation] Get Cookies ${cookies}= Get Cookies - Should Match Regexp ${cookies} ^(test=seleniumlibrary; another=value)|(another=value; test=seleniumlibrary)$ + Should Match Regexp ${cookies} + ... ^(test=seleniumlibrary; another=value)|(another=value; test=seleniumlibrary)$ Get Cookie Value Set By Selenium + [Documentation] Get Cookie Value Set By Selenium ${value}= Get Cookie Value another Should Be Equal ${value} value Get Cookie Value Set By App + [Documentation] Get Cookie Value Set By App Click Link Add cookie ${cookie}= Get Cookie Value spam Should Be Equal ${cookie} eggs App Sees Cookie Set By Selenium + [Documentation] App Sees Cookie Set By Selenium Add Cookie setbyselenium true Click Link Check cookie Element Text Should Be output Cookie found with value 'true'! Delete Cookie + [Documentation] Delete Cookie Delete Cookie test ${cookies} = Get Cookies Should Be Equal ${cookies} another=value Non-existent Cookie - Run Keyword And Expect Error ValueError: Cookie with name missing not found. Get Cookie Value missing + [Documentation] Non-existent Cookie + Run Keyword And Expect Error ValueError: Cookie with name missing not found. + ... Get Cookie Value missing Get Cookies When There Are None + [Documentation] Get Cookies When There Are None Delete All Cookies ${cookies}= Get Cookies Should Be Equal ${cookies} ${EMPTY} *** Keyword *** Add Cookies + [Documentation] Add Cookies Delete All Cookies Add Cookie test seleniumlibrary Add Cookie another value diff --git a/test/acceptance/keywords/element_should_be_enabled_and_disabled.robot b/test/acceptance/keywords/element_should_be_enabled_and_disabled.robot index b3f22830d..78e72dfa0 100644 --- a/test/acceptance/keywords/element_should_be_enabled_and_disabled.robot +++ b/test/acceptance/keywords/element_should_be_enabled_and_disabled.robot @@ -1,53 +1,67 @@ *** Settings *** -Test Setup Go To Page "forms/enabled_disabled_fields_form.html" -Resource ../resource.robot +Documentation Tests disabled elements +Test Setup Go To Page "forms/enabled_disabled_fields_form.html" +Resource ../resource.robot *** Test Cases *** Input Text - Should Be Enabled Not Disabled enabled_input - Should Be Disabled Not Enabled readonly_input - Should Be Disabled Not Enabled disabled_input + [Documentation] Input Text + Should Be Enabled Not Disabled enabled_input + Should Be Disabled Not Enabled readonly_input + Should Be Disabled Not Enabled disabled_input Input Password - Should Be Enabled Not Disabled enabled_password - Should Be Disabled Not Enabled readonly_password - Should Be Disabled Not Enabled disabled_password + [Documentation] Input Password + Should Be Enabled Not Disabled enabled_password + Should Be Disabled Not Enabled readonly_password + Should Be Disabled Not Enabled disabled_password Input Button - Should Be Enabled Not Disabled enabled_input_button - Should Be Disabled Not Enabled disabled_input_button + [Documentation] Input Button + Should Be Enabled Not Disabled enabled_input_button + Should Be Disabled Not Enabled disabled_input_button Textarea - Should Be Enabled Not Disabled enabled_textarea - Should Be Disabled Not Enabled readonly_textarea - Should Be Disabled Not Enabled disabled_textarea + [Documentation] Textarea + Should Be Enabled Not Disabled enabled_textarea + Should Be Disabled Not Enabled readonly_textarea + Should Be Disabled Not Enabled disabled_textarea Button - Should Be Enabled Not Disabled enabled_button - Should Be Disabled Not Enabled disabled_button + [Documentation] Button + Should Be Enabled Not Disabled enabled_button + Should Be Disabled Not Enabled disabled_button Option - Should Be Enabled Not Disabled enabled_option - Should Be Disabled Not Enabled disabled_option + [Documentation] Option + Should Be Enabled Not Disabled enabled_option + Should Be Disabled Not Enabled disabled_option Disabled with different syntaxes - Should Be Disabled Not Enabled disabled_only - Should Be Disabled Not Enabled disabled_with_equals_sign - Should Be Disabled Not Enabled disabled_empty - Should Be Disabled Not Enabled disabled_invalid_value + [Documentation] Disabled with different syntaxes + Should Be Disabled Not Enabled disabled_only + Should Be Disabled Not Enabled disabled_with_equals_sign + Should Be Disabled Not Enabled disabled_empty + Should Be Disabled Not Enabled disabled_invalid_value Not Input nor Editable Element - Run Keyword And Expect Error ERROR: Element table1 is not an input. Element Should Be Enabled table1 - Run Keyword And Expect Error ERROR: Element table1 is not an input. Element Should Be Disabled table1 + [Documentation] Not Input nor Editable Element + Run Keyword And Expect Error ERROR: Element table1 is not an input. + ... Element Should Be Enabled table1 + Run Keyword And Expect Error ERROR: Element table1 is not an input. + ... Element Should Be Disabled table1 *** Keywords *** Should Be Enabled Not Disabled - [Arguments] ${locator} - Element Should Be Enabled ${locator} - Run Keyword And Expect Error Element '${locator}' is enabled. Element Should Be Disabled ${locator} + [Documentation] Should Be Enabled Not Disabled + [Arguments] ${locator} + Element Should Be Enabled ${locator} + Run Keyword And Expect Error Element '${locator}' is enabled. + ... Element Should Be Disabled ${locator} Should Be Disabled Not Enabled - [Arguments] ${locator} - Element Should Be Disabled ${locator} - Run Keyword And Expect Error Element '${locator}' is disabled. Element Should Be Enabled ${locator} - + [Documentation] Should Be Disabled Not Enabled + [Arguments] ${locator} + Element Should Be Disabled ${locator} + Run Keyword And Expect Error Element '${locator}' is disabled. + ... Element Should Be Enabled ${locator} diff --git a/test/acceptance/keywords/elements.robot b/test/acceptance/keywords/elements.robot index 21706ce0a..660f708be 100644 --- a/test/acceptance/keywords/elements.robot +++ b/test/acceptance/keywords/elements.robot @@ -1,60 +1,71 @@ *** Settings *** -Test Setup Go To Page "links.html" -Resource ../resource.robot +Documentation Tests elements +Test Setup Go To Page "links.html" +Resource ../resource.robot *** Test Cases *** Get Elements - @{links}= Get WebElements //div[@id="div_id"]/a - Length Should Be ${links} 11 + [Documentation] Get Elements + @{links}= Get WebElements //div[@id="div_id"]/a + Length Should Be ${links} 11 Get Web Element - @{links}= Get WebElements //div[@id="div_id"]/a - ${link}= Get WebElement //div[@id="div_id"]/a - Should Be Equal @{links}[0] ${link} - Run Keyword and Expect Error ValueError: Element locator 'id=non_existing_elem' did not match any elements. - ... Get WebElement id=non_existing_elem + [Documentation] Get Web Element + @{links}= Get WebElements //div[@id="div_id"]/a + ${link}= Get WebElement //div[@id="div_id"]/a + Should Be Equal @{links}[0] ${link} + Run Keyword and Expect Error + ... ValueError: Element locator 'id=non_existing_elem' did not match any elements. + ... Get WebElement id=non_existing_elem More Get Elements - [Setup] Go To Page "forms/prefilled_email_form.html" - @{checkboxes}= Get WebElements //input[@type="checkbox"] - Length Should Be ${checkboxes} 2 - :For ${checkbox} in @{checkboxes} - \ Unselect Checkbox ${checkbox} - :For ${checkbox} in @{checkboxes} - \ Checkbox Should Not Be Selected ${checkbox} - :For ${checkbox} in @{checkboxes} - \ Select Checkbox ${checkbox} - :For ${checkbox} in @{checkboxes} - \ Checkbox Should Be Selected ${checkbox} + [Documentation] More Get Elements + [Setup] Go To Page "forms/prefilled_email_form.html" + @{checkboxes}= Get WebElements //input[@type="checkbox"] + Length Should Be ${checkboxes} 2 + : FOR ${checkbox} IN @{checkboxes} + \ Unselect Checkbox ${checkbox} + : FOR ${checkbox} IN @{checkboxes} + \ Checkbox Should Not Be Selected ${checkbox} + : FOR ${checkbox} IN @{checkboxes} + \ Select Checkbox ${checkbox} + : FOR ${checkbox} IN @{checkboxes} + \ Checkbox Should Be Selected ${checkbox} Assign Id To Element - [Documentation] Tests also Reload Page keyword. - Page Should Not Contain Element my id - Assign ID to Element xpath=//div[@id="first_div"] my id - Page Should Contain Element my id + [Documentation] Tests also Reload Page keyword. + Page Should Not Contain Element my id + Assign ID to Element xpath=//div[@id="first_div"] my id + Page Should Contain Element my id Reload Page - Page Should Not Contain Element my id + Page Should Not Contain Element my id Get Element Attribute - ${id}= Get Element Attribute link=Link with id@id - Should Be Equal ${id} some_id - ${id}= Get Element Attribute dom=document.getElementsByTagName('a')[3]@id - Should Be Equal ${id} some_id - ${class}= Get Element Attribute second_div@class - Should Be Equal ${class} Second Class + [Documentation] Get Element Attribute + ${id}= Get Element Attribute link=Link with id@id + Should Be Equal ${id} some_id + ${id}= Get Element Attribute dom=document.getElementsByTagName('a')[3]@id + Should Be Equal ${id} some_id + ${class}= Get Element Attribute second_div@class + Should Be Equal ${class} Second Class Get Matching XPath Count - ${count}= Get Matching XPath Count //a - Should Be Equal ${count} 19 - ${count}= Get Matching XPath Count //div[@id="first_div"]/a - Should Be Equal ${count} 2 + [Documentation] Get Matching XPath Count + ${count}= Get Matching XPath Count //a + Should Be Equal ${count} 19 + ${count}= Get Matching XPath Count //div[@id="first_div"]/a + Should Be Equal ${count} 2 Get Horizontal Position - ${pos}= Get Horizontal Position link=Link - Should Be True ${pos} > ${0} - Run Keyword And Expect Error Could not determine position for 'non-existent' Get Horizontal Position non-existent + [Documentation] Get Horizontal Position + ${pos}= Get Horizontal Position link=Link + Should Be True ${pos} > ${0} + Run Keyword And Expect Error Could not determine position for 'non-existent' + ... Get Horizontal Position non-existent Get Vertical Position - ${pos}= Get Vertical Position link=Link - Should Be True ${pos} > ${0} - Run Keyword And Expect Error Could not determine position for 'non-existent' Get Horizontal Position non-existent + [Documentation] Get Vertical Position + ${pos}= Get Vertical Position link=Link + Should Be True ${pos} > ${0} + Run Keyword And Expect Error Could not determine position for 'non-existent' + ... Get Horizontal Position non-existent diff --git a/test/acceptance/keywords/forms_and_buttons.robot b/test/acceptance/keywords/forms_and_buttons.robot index e388e9920..aac4a7444 100644 --- a/test/acceptance/keywords/forms_and_buttons.robot +++ b/test/acceptance/keywords/forms_and_buttons.robot @@ -1,75 +1,86 @@ *** Settings *** -Test Setup Go To Page "forms/named_submit_buttons.html" -Resource ../resource.robot -Library OperatingSystem - +Documentation Tests forms and buttons +Test Setup Go To Page "forms/named_submit_buttons.html" +Resource ../resource.robot +Library OperatingSystem *** Variables *** -${FORM SUBMITTED} forms/submit.html - +${FORM SUBMITTED} forms/submit.html *** Test Cases *** Submit Form - [Documentation] LOG 2 Submitting form 'form_name'. - Submit Form form_name + [Documentation] LOG 2 Submitting form 'form_name'. + Submit Form form_name Verify Location Is "${FORM SUBMITTED}" Submit Form Without Args - [Setup] Go To Page "forms/form_without_name.html" + [Documentation] Submit Form Without Args + [Setup] Go To Page "forms/form_without_name.html" Submit Form Verify Location Is "target/first.html" Click Ok Button By Name - [Documentation] LOG 2 Clicking button 'ok_button'. - Click Button ok_button + [Documentation] LOG 2 Clicking button 'ok_button'. + Click Button ok_button Verify Location Is "${FORM SUBMITTED}" Click Cancel Button By Name - Click Button cancel_button + [Documentation] Click Cancel Button By Name + Click Button cancel_button Value Should Be Cancel Click Ok Button By Value - Click Button Ok + [Documentation] Click Ok Button By Value + Click Button Ok Verify Location Is "${FORM SUBMITTED}" Click Cancel Button By Value - Click Button Cancel + [Documentation] Click Cancel Button By Value + Click Button Cancel Value Should Be Cancel Click button created with