Merge pull request #59 from seleniumbase/defaults_update

Defaults update and adding a command line option for highlight animations
This commit is contained in:
Michael Mintz 2016-07-20 02:54:37 -04:00 committed by GitHub
commit 80b5a04334
4 changed files with 20 additions and 5 deletions

View File

@ -19,7 +19,12 @@ EXTREME_TIMEOUT = 30
# Use Demo Mode when you want others to see what your automation is doing
# Usage: --demo_mode when run from the command line when using --with-selenium
# This value can be overwritten on the command line by using --demo_sleep=FLOAT
DEFAULT_DEMO_MODE_TIMEOUT = 1.2
DEFAULT_DEMO_MODE_TIMEOUT = 1.0
# Number of times to repeat the highlight animation. (Seen during Demo Mode)
# Each loop is about 0.18 seconds.
# This value can be overwritten on the command line by using --highlights=TIMES
HIGHLIGHTS = 4
# If True, existing logs from past test runs will be saved and take up space.
# If False, only the logs from the most recent test run will be saved locally.

View File

@ -261,14 +261,15 @@ class BaseCase(unittest.TestCase):
# Since jQuery still isn't activating, give up and raise an exception
raise Exception("Exception: WebDriver could not activate jQuery!")
def highlight(self, selector, by=By.CSS_SELECTOR, loops=4, scroll=True):
def highlight(self, selector, by=By.CSS_SELECTOR,
loops=settings.HIGHLIGHTS, scroll=True):
""" This method uses fancy javascript to highlight an element.
Used during demo_mode.
@Params
selector - the selector of the element to find
by - the type of selector to search by (Default: CSS)
loops - # of times to repeat the highlight animation (Default: 4)
(4 loops is about 0.70 seconds. Your mileage may vary)
loops - # of times to repeat the highlight animation
(Default: 4. Each loop lasts for about 0.18s)
scroll - the option to scroll to the element first (Default: True)
"""
element = self.find_element(
@ -302,6 +303,8 @@ class BaseCase(unittest.TestCase):
except Exception:
self.activate_jquery()
self.execute_script(script)
if self.highlights:
loops = self.highlights
loops = int(loops)
for n in xrange(loops):
script = """jQuery('%s').css('box-shadow',
@ -844,6 +847,7 @@ class BaseCase(unittest.TestCase):
self.data = pytest.config.option.data
self.demo_mode = pytest.config.option.demo_mode
self.demo_sleep = pytest.config.option.demo_sleep
self.highlights = pytest.config.option.highlights
if self.with_db_reporting:
self.execution_guid = str(uuid.uuid4())
self.testcase_guid = None

View File

@ -25,6 +25,7 @@ class SeleniumBrowser(Plugin):
self.options.headless -- the option to run headlessly (--headless)
self.options.demo_mode -- the option to slow down Selenium (--demo_mode)
self.options.demo_sleep -- Selenium action delay in DemoMode (--demo_sleep)
self.options.highlights -- # of highlight animations shown (--highlights)
"""
name = 'selenium' # Usage: --with-selenium
@ -64,6 +65,10 @@ class SeleniumBrowser(Plugin):
default=None,
help="""Setting this overrides the Demo Mode sleep
time that happens after browser actions.""")
parser.add_option('--highlights', action='store',
dest='highlights', default=None,
help="""Setting this overrides the default number of
highlight loops to have.""")
def configure(self, options, conf):
super(SeleniumBrowser, self).configure(options, conf)
@ -120,6 +125,7 @@ class SeleniumBrowser(Plugin):
test.test.browser = "%s%s" % (self.options.browser, version)
test.test.demo_mode = self.options.demo_mode
test.test.demo_sleep = self.options.demo_sleep
test.test.highlights = self.options.highlights
except Exception as err:
print("Error starting/connecting to Selenium:")
print(err)

View File

@ -6,7 +6,7 @@ from setuptools import setup, find_packages # noqa
setup(
name='seleniumbase',
version='1.2.0',
version='1.2.1',
url='http://seleniumbase.com',
author='Michael Mintz',
author_email='@mintzworld',