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
56 changes: 30 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
#!/usr/bin/env python

import os, sys
from setuptools import setup, find_packages

THIS_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(THIS_DIR, "src", "Selenium2Library"))
VERSION = '0.5.3'

from distutils.core import setup
import metadata
DESCRIPTION = """
Selenium2Library is a web testing library for Robot Framework
that leverage the Selenium 2 (WebDriver) libraries.
"""[1:-1]

def main():
setup(
name = metadata.NAME,
version = metadata.VERSION,
description = metadata.SHORT_DESCRIPTION,
long_description = metadata.LONG_DESCRIPTION,
author = metadata.AUTHOR,
author_email = metadata.AUTHOR_EMAIL,
url = metadata.PROJECT_URL,
license = metadata.LICENSE,
keywords = metadata.KEYWORDS,
platforms = metadata.PLATFORMS,
classifiers = metadata.TROVE_CLASSIFIERS,
package_dir = {'' : 'src'},
packages = metadata.get_all_packages(),
package_data = metadata.get_all_package_data(),
)


if __name__ == '__main__':
main()
setup(name = 'robotframework-selenium2library',
version = VERSION,
description = 'Web testing library for Robot Framework',
long_description = DESCRIPTION,
author = 'Robot Framework Developers',
author_email = '[email protected]',
url = 'https://github.com/rtomac/robotframework-selenium2library',
license = 'Apache License 2.0',
keywords = 'robotframework testing testautomation selenium selenium2 webdriver web',
platforms = 'any',
classifiers = [
"Development Status :: 4 - Beta",
#"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Software Development :: Testing"
],
install_requires = ['decorator >= 3.3.2',
'selenium >= 2.8.1', ],
package_dir = {'' : 'src'},
packages = find_packages('src', exclude=['ez_setup']),
include_package_data = True,
)
14 changes: 6 additions & 8 deletions src/Selenium2Library/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
import os
import sys

ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(ROOT_DIR, "lib", "selenium-2.8.1", "py"))
sys.path.insert(0, os.path.join(ROOT_DIR, "lib", "decorator-3.3.2"))

from keywords import *
from metadata import VERSION

Expand Down Expand Up @@ -90,12 +83,16 @@ class Selenium2Library(
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
ROBOT_LIBRARY_VERSION = VERSION

def __init__(self, timeout=5.0, run_on_failure='Capture Page Screenshot'):
def __init__(self, timeout=5.0, implicit_wait=5.0, run_on_failure='Capture Page Screenshot'):
"""Selenium2Library can be imported with optional arguments.

`timeout` is the default timeout used to wait for all waiting actions.
It can be later set with `Set Selenium Timeout`.

'implicit_wait' is the implicit timeout that Selenium waits when
looking for elements.
It can be later set with 'Set Selenium Implicit Wait'.

`run_on_failure` specifies the name of a keyword (from any available
libraries) to execute when a Selenium2Library keyword fails. By default
`Capture Page Screenshot` will be used to take a screenshot of the current page.
Expand All @@ -111,4 +108,5 @@ def __init__(self, timeout=5.0, run_on_failure='Capture Page Screenshot'):
for base in Selenium2Library.__bases__:
base.__init__(self)
self.set_selenium_timeout(timeout)
self.set_selenium_implicit_wait(implicit_wait)
self.register_keyword_to_run_on_failure(run_on_failure)
24 changes: 24 additions & 0 deletions src/Selenium2Library/keywords/_browsermanagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(self):
self._window_manager = WindowManager()
self._speed_in_secs = float(0)
self._timeout_in_secs = float(5)
self._implicit_wait_in_secs = float(5)

# Public, open and close

Expand Down Expand Up @@ -278,6 +279,12 @@ def get_selenium_timeout(self):
See `Set Selenium Timeout` for an explanation."""
return robot.utils.secs_to_timestr(self._timeout_in_secs)

def get_selenium_implicit_wait(self):
"""Gets the wait in seconds that is waited by Selenium.

See `Set Selenium Implicit Wait` for an explanation."""
return robot.utils.secs_to_timestr(self._implicit_wait_in_secs)

def set_selenium_speed(self, seconds):
"""Sets the delay in seconds that is waited after each Selenium command.

Expand Down Expand Up @@ -315,6 +322,23 @@ def set_selenium_timeout(self, seconds):
self._timeout_in_secs = robot.utils.timestr_to_secs(seconds)
return old_timeout

def set_selenium_implicit_wait(self, seconds):
"""Sets Selenium 2's implicit wait in seconds.

From selenium 2 function 'Sets a sticky timeout to implicitly
wait for an element to be found, or a command to complete.
This method only needs to be called one time per session.'

Example:
| ${orig wait} = | Set Selenium Implicit Wait | 10 seconds |
| Perform AJAX call that is slow |
| Set Selenium Implicit Wait | ${orig wait} |
"""
old_wait = self._implicit_wait_in_secs
for browser in self._cache.browsers:
browser.implicitly_wait(self._implicit_wait_in_secs)
return old_wait

# Private

def _current_browser(self):
Expand Down
210 changes: 0 additions & 210 deletions src/Selenium2Library/lib/decorator-3.3.2/decorator.py

This file was deleted.

Loading