Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 42 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,51 @@ addons:
firefox: latest-esr
language: python
sudo: false
python:
- "2.7"
install:
#- pip install pep8 --use-mirrors
#- pip install pyflakes --use-mirrors
- pip install robotframework
- pip install selenium==2.53.6
- pip install decorator
- pip install mockito
#- "if [[ ${BROWSER} == 'ie' ]]; then pip install ie_only_pkg; fi"
- pip install .
- pip install -r requirements.txt
- pip install -r requirements-dev.txt
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
script:
- "firefox --version"
- "python test/run_tests.py python $BROWSER --noncritical known_issue_-_travisci"
- "if [[ -n ${SELENIUM_VERSION+x} ]]; then pip install -U selenium==${SELENIUM_VERSION}; fi"
- "python test/run_tests.py python \"$BROWSER\""
env:
matrix:
- BROWSER=firefox
#- BROWSER=ie # will be added when we have completed SauceLabs CI
#- BROWSER=safari # will be added after #247 merged
global:
- secure: "QyY0j8C+hVhsGLv4YU0UMvLm5wBDg6xT5J0Ee77C/JAQ6vcdCMpTfWI8oDxTZb7pBhpDkYuNe747yCYF5PrdBYQbO08FilxctReuJfMXcH44rZC5q49mUmPamkvg1LkzIWuC1s9uKnjlvyDT5ojuPXZl2Vn0gIhSIg+yOyBkM1U="

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the Sauce Labs hash keys to access the account. You have the clear passwords saved in somewhere? Perhaps we should distribute the password with wider audience but not put the passwords in git repo.

Is there reason why the are two secure lines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these are encoded login and password for sauce labs. They can be securely stored in repo because they can be decoded only in travis env.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this is good to go then.

- secure: "HJaJTYauaBZODMDkbnRVsiCk+t2uVtztkkJ5V4dXSnE1uIBms2PVbufQwb+YNvzHkGheLtpnt/hLM1HhmSFgUtOCf+eumQ6kaLR2KRVEysXwWJzgZoLBidNBOy5rvAIsc9JJbDaIgYVGzyaJGTP9AMb8CyvIPE//lH10sf+GB7g="
matrix:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add some run with Python 3 too. Example have to runs with Chrome one with Python 2.7 and another one with Python 3.

@drobota drobota Dec 9, 2016 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add it, but does s2l compatible with py3?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it is not yet compatible. But the aim for the 2.0 release, which hopefully is the next release, is to make it compatible with Python 3.

include:
- os: linux
env:
- BROWSER=firefox
- SELENIUM_VERSION=2.53.6
addons:
firefox: "47.0.1"
python: "2.7"
- os: linux
env:
- BROWSER=chrome
addons:
sauce_connect: true
python: "2.7"
- os: linux
env:
- BROWSER=firefox
- SELENIUM_VERSION=2.53.6
addons:
sauce_connect: true
python: "3.4"
- os: linux
env:
- BROWSER="internet explorer"
addons:
sauce_connect: true
python: "2.7"
- os: linux
env:
- BROWSER=safari
addons:
sauce_connect: true
python: "2.7"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
decorator >= 3.3.2
selenium >= 2.32.0
selenium
robotframework >= 2.6.0
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python

from os.path import abspath, dirname, join

from setuptools import setup


Expand Down
43 changes: 26 additions & 17 deletions src/Selenium2Library/keywords/_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
from Selenium2Library import utils
from Selenium2Library.locators import ElementFinder
from Selenium2Library.locators import CustomLocator
from Selenium2Library.keywords.keywordgroup import KeywordGroup

from .keywordgroup import KeywordGroup
try:
basestring # attempt to evaluate basestring

def isstr(s):
return isinstance(s, basestring)
except NameError:
def isstr(s):
return isinstance(s, str)


class _ElementKeywords(KeywordGroup):
Expand Down Expand Up @@ -358,9 +366,11 @@ def click_element_at_coordinates(self, locator, xoffset, yoffset):
"""
self._info("Click clicking element '%s' in coordinates '%s', '%s'." % (locator, xoffset, yoffset))
element = self._element_find(locator, True, True)
#self._element_find(locator, True, True).click()
#ActionChains(self._current_browser()).move_to_element_with_offset(element, xoffset, yoffset).click().perform()
ActionChains(self._current_browser()).move_to_element(element).move_by_offset(xoffset, yoffset).click().perform()
action = ActionChains(self._current_browser())
action.move_to_element(element)
action.move_by_offset(xoffset, yoffset)
action.click()
action.perform()

def double_click_element(self, locator):
"""Double click element identified by `locator`.
Expand Down Expand Up @@ -389,11 +399,10 @@ def drag_and_drop(self, source, target):
Examples:
| Drag And Drop | elem1 | elem2 | # Move elem1 over elem2. |
"""
src_elem = self._element_find(source,True,True)
trg_elem = self._element_find(target,True,True)
src_elem = self._element_find(source, True, True)
trg_elem = self._element_find(target, True, True)
ActionChains(self._current_browser()).drag_and_drop(src_elem, trg_elem).perform()


def drag_and_drop_by_offset(self, source, xoffset, yoffset):
"""Drags element identified with `source` which is a locator.

Expand All @@ -404,7 +413,9 @@ def drag_and_drop_by_offset(self, source, xoffset, yoffset):
| Drag And Drop By Offset | myElem | 50 | -35 | # Move myElem 50px right and 35px down. |
"""
src_elem = self._element_find(source, True, True)
ActionChains(self._current_browser()).drag_and_drop_by_offset(src_elem, xoffset, yoffset).perform()
action = ActionChains(self._current_browser())
action.drag_and_drop_by_offset(src_elem, xoffset, yoffset)
action.perform()

def mouse_down(self, locator):
"""Simulates pressing the left mouse button on the element specified by `locator`.
Expand Down Expand Up @@ -582,7 +593,6 @@ def mouse_down_on_image(self, locator):

def page_should_contain_image(self, locator, message='', loglevel='INFO'):
"""Verifies image identified by `locator` is found from current page.

See `Page Should Contain Element` for explanation about `message` and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think empty line should have not been removed.

`loglevel` arguments.

Expand Down Expand Up @@ -723,7 +733,7 @@ def _is_enabled(self, locator):
return True

def _is_text_present(self, text):
locator = "xpath=//*[contains(., %s)]" % utils.escape_xpath_value(text);
locator = "xpath=//*[contains(., %s)]" % utils.escape_xpath_value(text)
return self._is_element_present(locator)

def _is_visible(self, locator):
Expand Down Expand Up @@ -759,22 +769,22 @@ 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)
return getattr(Keys, key_name)
except AttributeError:
message = "Unknown key named '%s'." % (key_name)
self._debug(message)
raise ValueError(message)
message = "Unknown key named '%s'." % (key_name)
self._debug(message)
raise ValueError(message)

def _parse_attribute_locator(self, attribute_locator):
parts = attribute_locator.rpartition('@')
if len(parts[0]) == 0:
raise ValueError("Attribute locator '%s' does not contain an element locator." % (attribute_locator))
if len(parts[2]) == 0:
raise ValueError("Attribute locator '%s' does not contain an attribute name." % (attribute_locator))
return (parts[0], parts[2])
return parts[0], parts[2]

def _is_element_present(self, locator, tag=None):
return (self._element_find(locator, True, False, tag=tag) is not None)
return self._element_find(locator, True, False, tag=tag) is not None

def _page_contains(self, text):
browser = self._current_browser()
Expand All @@ -791,7 +801,6 @@ def _page_contains(self, text):
browser.switch_to_default_content()
if found_text:
return True

return False

def _page_should_contain_element(self, locator, tag, message, loglevel):
Expand Down
5 changes: 3 additions & 2 deletions test/acceptance/create_webdriver.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ Library Collections
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|-)+
[Tags] Known Issue Chrome Known Issue Internet Explorer Known Issue Safari

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we document the tags we use, so that people contributing could also use them right?

[Setup] Set Driver Variables
Create Webdriver ${DRIVER_NAME} kwargs=${KWARGS}
Go To ${FRONT PAGE}
Page Should Contain needle
Go To ${FRONT_PAGE}
Wait Until Page Contains needle 5s
[Teardown] Close Browser

Create Webdriver With Bad Driver Name
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/keywords/click_element.robot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Click Element

Double Click Element
[Documentation] LOG 2 Double clicking element 'doubleClickButton'.
[Tags] Known Issue - Firefox
[Tags] Known Issue Safari Known Issue Firefox
Double Click Element doubleClickButton
Element Text Should Be output double clicked

Expand Down
4 changes: 3 additions & 1 deletion test/acceptance/keywords/click_element_at_coordinates.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Resource ../resource.robot
*** Test Cases ***
Click Element At Coordinates
[Documentation] LOG 2 Click clicking element 'Clickable' in coordinates '10', '20'.
[Tags] Known Issue - Firefox
[Tags] Known Issue Firefox
... Known Issue Internet Explorer
... Known Issue Safari
Click Element At Coordinates Clickable ${10} ${20}
Element Text Should Be outputX 110
Element Text Should Be outputY 120
Expand Down
2 changes: 2 additions & 0 deletions test/acceptance/keywords/cookies.robot
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ App Sees Cookie Set By Selenium

Delete Cookie
[Documentation] Delete Cookie
[Tags] Known Issue Safari
Delete Cookie test
${cookies} = Get Cookies
Should Be Equal ${cookies} another=value
Expand All @@ -42,6 +43,7 @@ Non-existent Cookie

Get Cookies When There Are None
[Documentation] Get Cookies When There Are None
[Tags] Known Issue Safari
Delete All Cookies
${cookies}= Get Cookies
Should Be Equal ${cookies} ${EMPTY}
Expand Down
11 changes: 6 additions & 5 deletions test/acceptance/keywords/elements.robot
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ Get Vertical Position


Get Element Size
${width} ${height}= Get Element Size link=Link
Should be True ${height} > ${0}
Should be True ${width} > ${0}
Run Keyword And Expect Error ValueError: Element locator 'non-existent' did not match any elements. Get Element Size non-existent
${width} ${height}= Get Element Size link=Link
Should be True ${height} > ${0}
Should be True ${width} > ${0}
Run Keyword And Expect Error ValueError: Element locator 'non-existent' did not match any elements. Get Element Size non-existent

Get Empty Element Size
[Tags] Known Issue Internet Explorer
${width} ${height}= Get Element Size id=emptyDiv
Should be True ${height} == 0
Should be True ${height} == 0
1 change: 1 addition & 0 deletions test/acceptance/keywords/forms_and_buttons.robot
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Click button created with <button> by tag content
Choose File
[Documentation] Choose File
[Setup] Navigate To File Upload Form And Create Temp File To Upload
[Tags] Known Issue Internet Explorer Known Issue Safari
Choose File file_to_upload ${CURDIR}${/}temp.txt
${dep_browser}= Set Variable If
... '${BROWSER}'.lower() == 'ff' or '${BROWSER}'.lower() == 'firefox'
Expand Down
12 changes: 10 additions & 2 deletions test/acceptance/keywords/javascript.robot
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Clicking Elements Should Activate Javascript

Alert Should Be Present
[Documentation] Alert Should Be Present
[Tags] Known Issue Safari
[Setup] Go To Page "javascript/alert.html"
Click Link Click Me!
Alert Should Be Present
Expand All @@ -23,6 +24,7 @@ Alert Should Be Present

Get Alert Message
[Documentation] Get Alert Message
[Tags] Known Issue Safari
[Setup] Go To Page "javascript/alert.html"
Click Link Click Me!
${msg} = Get Alert Message
Expand All @@ -31,6 +33,7 @@ Get Alert Message

Read Alert Message
[Documentation] Read Alert Message
[Tags] Known Issue Safari
[Setup] Go To Page "javascript/alert.html"
Click Link Click Me!
${msg} = Get Alert Message ${FALSE}
Expand All @@ -40,6 +43,7 @@ Read Alert Message

Input Text Into Prompt
[Documentation] Input Text Into Prompt
[Tags] Known Issue Safari
[Setup] Go To Page "javascript/alert_prompt.html"
Click Element css=button
Input Text Into Prompt myname
Expand All @@ -48,7 +52,7 @@ Input Text Into Prompt

Mouse Down On Link
[Documentation] Mouse Down On Link
[Tags] Known Issue - Firefox
[Tags] Known Issue Safari Known Issue Firefox
[Setup] Go To Page "javascript/mouse_events.html"
Mouse Down On Image image_mousedown
Text Field Should Contain textfield onmousedown
Expand All @@ -60,13 +64,15 @@ Mouse Down On Link

Confirm Action
[Documentation] Confirm Action
[Tags] Known Issue Safari
Click Button Change the title
${msg}= Confirm Action
Title Should Be Changed after confirmation
Should Be Equal ${msg} Really change the title?

Cancel Action
[Documentation] Cancel Action
[Tags] Known Issue Safari
Choose Cancel On Next Confirmation
Click Button Change the title
${msg}= Confirm Action
Expand All @@ -88,19 +94,21 @@ Execute Javascript from File

Open Context Menu
[Documentation] Open Context Menu
[Tags] Known Issue - Firefox
[Tags] Known Issue Safari Known Issue Firefox
Go To Page "javascript/context_menu.html"
Open Context Menu myDiv

Drag and Drop
[Documentation] Drag and Drop
[Tags] Known Issue Internet Explorer Known Issue Safari
[Setup] Go To Page "javascript/drag_and_drop.html"
Element Text Should Be id=droppable Drop here
Drag and Drop id=draggable id=droppable
Element Text Should Be id=droppable Dropped!

Drag and Drop by Offset
[Documentation] Drag and Drop by Offset
[Tags] Known Issue Internet Explorer Known Issue Safari
[Setup] Go To Page "javascript/drag_and_drop.html"
Element Text Should Be id=droppable Drop here
Drag and Drop by Offset id=draggable ${1} ${1}
Expand Down
1 change: 1 addition & 0 deletions test/acceptance/keywords/lists.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Documentation Tests lists
Test Setup Go To Page "forms/prefilled_email_form.html"
Resource ../resource.robot
Force Tags Known Issue Internet Explorer

*** Test Cases ***
Get List Items From Single-Select List
Expand Down
9 changes: 5 additions & 4 deletions test/acceptance/keywords/mouse.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@
Documentation Tests mouse
Test Setup Go To Page "mouse/index.html"
Resource ../resource.robot
Force Tags Known Issue Internet Explorer

*** Test Cases ***
Mouse Over
[Documentation] Mouse Over
[Tags] Known Issue - Firefox
[Tags] Known Issue Safari Known Issue Firefox
Mouse Over el_for_mouseover
Textfield Value Should Be el_for_mouseover mouseover el_for_mouseover
Run Keyword And Expect Error ERROR: Element not_there not found. Mouse Over not_there

Mouse Out
[Documentation] Mouse Out
[Tags] Known Issue - Firefox
[Tags] Known Issue Safari Known Issue Firefox
Mouse Out el_for_mouseout
Textfield Value Should Be el_for_mouseout mouseout el_for_mouseout
Run Keyword And Expect Error ERROR: Element not_there not found. Mouse Out not_there

Mouse Down
[Documentation] Mouse Down
[Tags] Known Issue - Firefox
[Tags] Known Issue Safari Known Issue Firefox
Mouse Down el_for_mousedown
Textfield Value Should Be el_for_mousedown mousedown el_for_mousedown
Run Keyword And Expect Error ERROR: Element not_there not found. Mouse Down not_there

Mouse Up
[Documentation] Mouse Up
[Tags] Known Issue - Firefox
[Tags] Known Issue Safari Known Issue Firefox
Mouse Up el_for_mouseup
Textfield Value Should Be el_for_mouseup mouseup el_for_mouseup
Run Keyword And Expect Error ERROR: Element not_there not found. Mouse Up not_there
Expand Down
Loading