Skip to content

Commit

Permalink
Merge pull request #7 from jamalex/exercisedescriptionerror
Browse files Browse the repository at this point in the history
Added ability to specify in settings to only run fast tests.
  • Loading branch information
ruimalheiro committed Aug 15, 2013
2 parents e03acc9 + a0084af commit 1f3503c
Show file tree
Hide file tree
Showing 28 changed files with 448 additions and 153 deletions.
1 change: 1 addition & 0 deletions kalite/main/tests/browser_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ def setUp(self):
super(LoadExerciseTest, self).setUp()
self.driver = WebDriver()

@unittest.skipIf(settings.FAST_TESTS_ONLY, "Skipping slow test")
def test_get_exercise_load_status(self):
for path in get_exercise_paths():
logging.debug("Testing path : " + path)
Expand Down
2 changes: 2 additions & 0 deletions kalite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@

TEST_RUNNER = 'kalite.utils.testing.testrunner.KALiteTestRunner'

FAST_TESTS_ONLY = getattr(local_settings, "FAST_TESTS_ONLY", False)

CRONSERVER_FREQUENCY = getattr(local_settings, "CRONSERVER_FREQUENCY", 600) # 10 mins (in seconds)

# Add additional mimetypes to avoid errors/warnings
Expand Down
2 changes: 1 addition & 1 deletion python-packages/selenium/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
from selenium import selenium


__version__ = "2.32.0"
__version__ = "2.35.0"
98 changes: 75 additions & 23 deletions python-packages/selenium/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Exceptions that may happen in all the webdriver code."""
"""
Exceptions that may happen in all the webdriver code.
"""

class WebDriverException(Exception):
"""
Base webdriver exception.
"""

def __init__(self, msg=None, screen=None, stacktrace=None):
self.msg = msg
self.screen = screen
Expand All @@ -27,99 +34,144 @@ def __str__(self):
% exception_msg
if self.stacktrace is not None:
exception_msg = "%s; Stacktrace: %s " \
% (exception_msg, str(self.stacktrace))
% (exception_msg, str("\n" + "\n".join(self.stacktrace)))
return exception_msg

class ErrorInResponseException(WebDriverException):
"""An error has occurred on the server side.
"""
Thrown when an error has occurred on the server side.
This may happen when communicating with the firefox extension
or the remote driver server."""
or the remote driver server.
"""
def __init__(self, response, msg):
WebDriverException.__init__(self, msg)
self.response = response

class InvalidSwitchToTargetException(WebDriverException):
"""The frame or window target to be switched doesn't exist."""
"""
Thrown when frame or window target to be switched doesn't exist.
"""
pass

class NoSuchFrameException(InvalidSwitchToTargetException):
"""
Thrown when frame target to be switched doesn't exist.
"""
pass

class NoSuchWindowException(InvalidSwitchToTargetException):
"""
Thrown when window target to be switched doesn't exist.
"""
pass

class NoSuchElementException(WebDriverException):
"""find_element_by_* can't find the element."""
"""
Thrown when element could not be found.
"""
pass

class NoSuchAttributeException(WebDriverException):
"""find_element_by_* can't find the element."""
"""
Thrown when the attribute of element could not be found.
"""
pass

class StaleElementReferenceException(WebDriverException):
"""Indicates that a reference to an element is now "stale" --- the
element no longer appears on the DOM of the page."""
"""
Thrown when a reference to an element is now "stale".
Stale means the element no longer appears on the DOM of the page.
"""
pass

class InvalidElementStateException(WebDriverException):
class InvalidElementStateException(WebDriverException):
"""
"""
pass

class UnexpectedAlertPresentException(WebDriverException):
"""
Thrown when an unexpected alert is appeared.
"""
pass

class NoAlertPresentException(WebDriverException):
"""
Thrown when switching to no presented alert.
"""
pass

class ElementNotVisibleException(InvalidElementStateException):
"""Thrown to indicate that although an element is present on the
DOM, it is not visible, and so is not able to be interacted
with."""
"""
Thrown when although an element is present on the DOM,
it is not visible, and so is not able to be interacted with.
"""
pass

class ElementNotSelectableException(InvalidElementStateException):
"""
Thrown when trying to select an unselectable element.
"""
pass

class InvalidCookieDomainException(WebDriverException):
"""Thrown when attempting to add a cookie under a different domain
than the current URL."""
"""
Thrown when attempting to add a cookie under a different domain
than the current URL.
"""
pass

class UnableToSetCookieException(WebDriverException):
"""Thrown when a driver fails to set a cookie."""
"""
Thrown when a driver fails to set a cookie.
"""
pass

class RemoteDriverServerException(WebDriverException):
"""
"""
pass

class TimeoutException(WebDriverException):
"""Thrown when a command does not complete in enough time."""
"""
Thrown when a command does not complete in enough time.
"""
pass

class MoveTargetOutOfBoundsException(WebDriverException):
"""Indicates that the target provided to the actions move() method is invalid"""
"""
Thrown when the target provided to the `ActionsChains` move()
method is invalid, i.e. out of document.
"""
pass

class UnexpectedTagNameException(WebDriverException):
"""Thrown when a support class did not get an expected web element"""
"""
Thrown when a support class did not get an expected web element.
"""
pass

class InvalidSelectorException(NoSuchElementException):
""" Thrown when the selector which is used to find an element does not return
"""
Thrown when the selector which is used to find an element does not return
a WebElement. Currently this only happens when the selector is an xpath
expression is used which is either syntactically invalid (i.e. it is not a
expression and it is either syntactically invalid (i.e. it is not a
xpath expression) or the expression does not select WebElements
(e.g. "count(//input)").
"""
pass

class ImeNotAvailableException(WebDriverException):
"""
Indicates that IME support is not available. This exception is thrown for every IME-related
Thrown when IME support is not available. This exception is thrown for every IME-related
method call if IME support is not available on the machine.
"""
pass

class ImeActivationFailedException(WebDriverException):
""" Indicates that activating an IME engine has failed. """
"""
Thrown when activating an IME engine has failed.
"""
pass
3 changes: 1 addition & 2 deletions python-packages/selenium/selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ def start(self, browserConfigurationOptions=None, driver=None):
if browserConfigurationOptions:
start_args.append(browserConfigurationOptions)
if driver:
id = driver.desired_capabilities['webdriver.remote.sessionid']
start_args.append('webdriver.remote.sessionid=%s' % id)
start_args.append('webdriver.remote.sessionid=%s' % driver.session_id)
result = self.get_string("getNewBrowserSession", start_args)
try:
self.sessionId = result
Expand Down
2 changes: 1 addition & 1 deletion python-packages/selenium/webdriver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
from .common.touch_actions import TouchActions
from .common.proxy import Proxy

__version__ = '2.32.0'
__version__ = '2.35.0'
2 changes: 1 addition & 1 deletion python-packages/selenium/webdriver/chrome/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def extensions(self):
"""
encoded_extensions = []
for ext in self._extension_files:
file_ = open(ext)
file_ = open(ext, 'rb')
# Should not use base64.encodestring() which inserts newlines every
# 76 characters (per RFC 1521). Chromedriver has to remove those
# unnecessary newlines before decoding, causing performance hit.
Expand Down
32 changes: 18 additions & 14 deletions python-packages/selenium/webdriver/common/action_chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
# limitations under the License.

"""
The ActionChains implementation
The ActionChains implementation,
"""
from selenium.webdriver.remote.command import Command
from selenium.webdriver.common.keys import Keys

class ActionChains(object):
"""
Generate user actions.
All actions are stored in the ActionChains object. Call perform() to fire
stored actions.
All actions are stored in the ActionChains object.
Call perform() to fire stored actions.
"""

def __init__(self, driver):
Expand Down Expand Up @@ -96,7 +96,8 @@ def double_click(self, on_element=None):
return self

def drag_and_drop(self, source, target):
"""Holds down the left mouse button on the source element,
"""
Holds down the left mouse button on the source element,
then moves to the target element and releases the mouse button.
:Args:
Expand All @@ -110,7 +111,7 @@ def drag_and_drop(self, source, target):
def drag_and_drop_by_offset(self, source, xoffset, yoffset):
"""
Holds down the left mouse button on the source element,
then moves to the target element and releases the mouse button.
then moves to the target offset and releases the mouse button.
:Args:
- source: The element to mouse down.
Expand All @@ -123,12 +124,13 @@ def drag_and_drop_by_offset(self, source, xoffset, yoffset):
return self

def key_down(self, value, element=None):
"""Sends a key press only, without releasing it.
Should only be used with modifier keys (Control, Alt and Shift).
"""
Sends a key press only, without releasing it.
Should only be used with modifier keys (Control, Alt and Shift).
:Args:
- key: The modifier key to send. Values are defined in Keys class.
- target: The element to send keys.
- value: The modifier key to send. Values are defined in `Keys` class.
- element: The element to send keys.
If None, sends a key to current focused element.
"""
typing = []
Expand All @@ -154,8 +156,8 @@ def key_up(self, value, element=None):
Releases a modifier key.
:Args:
- key: The modifier key to send. Values are defined in Keys class.
- target: The element to send keys.
- value: The modifier key to send. Values are defined in Keys class.
- element: The element to send keys.
If None, sends a key to current focused element.
"""
typing = []
Expand Down Expand Up @@ -204,7 +206,7 @@ def move_to_element(self, to_element):
def move_to_element_with_offset(self, to_element, xoffset, yoffset):
"""
Move the mouse by an offset of the specificed element.
Offsets are relative to the top-left corner of the element.
Offsets are relative to the top-left corner of the element.
:Args:
- to_element: The element to move to.
Expand All @@ -220,18 +222,20 @@ def move_to_element_with_offset(self, to_element, xoffset, yoffset):

def release(self, on_element=None):
"""
Releasing a held mouse button.
Releasing a held mouse button on an element.
:Args:
- on_element: The element to mouse up.
If None, releases on current mouse position.
"""
if on_element: self.move_to_element(on_element)
self._actions.append(lambda:
self._driver.execute(Command.MOUSE_UP, {}))
return self

def send_keys(self, *keys_to_send):
"""Sends keys to current focused element.
"""
Sends keys to current focused element.
:Args:
- keys_to_send: The keys to send.
Expand Down
32 changes: 28 additions & 4 deletions python-packages/selenium/webdriver/common/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,51 @@
#See the License for the specific language governing permissions and
#limitations under the License.

"""
The Alert implementation.
"""

from selenium.webdriver.remote.command import Command


class Alert(object):
"""
Allows to work wit alerts.
"""

def __init__(self, driver):
"""
Creates a new Alert.
:Args:
- driver: The WebDriver instance which performs user actions.
"""
self.driver = driver

@property
def text(self):
""" Gets the text of the Alert """
"""
Gets the text of the Alert.
"""
return self.driver.execute(Command.GET_ALERT_TEXT)["value"]

def dismiss(self):
""" Dismisses the alert available """
"""
Dismisses the alert available.
"""
self.driver.execute(Command.DISMISS_ALERT)

def accept(self):
""" Accepts the alert available """
"""
Accepts the alert available.
"""
self.driver.execute(Command.ACCEPT_ALERT)

def send_keys(self, keysToSend):
""" Send Keys to the Alert """
"""
Send Keys to the Alert.
:Args:
- keysToSend: The text to be sent to Alert.
"""
self.driver.execute(Command.SET_ALERT_VALUE, {'text': keysToSend})
Loading

0 comments on commit 1f3503c

Please sign in to comment.