Merge pull request #59 from seleniumbase/defaults_update
Defaults update and adding a command line option for highlight animations
This commit is contained in:
commit
80b5a04334
|
@ -19,7 +19,12 @@ EXTREME_TIMEOUT = 30
|
||||||
# Use Demo Mode when you want others to see what your automation is doing
|
# 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
|
# 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
|
# 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 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.
|
# If False, only the logs from the most recent test run will be saved locally.
|
||||||
|
|
|
@ -261,14 +261,15 @@ class BaseCase(unittest.TestCase):
|
||||||
# Since jQuery still isn't activating, give up and raise an exception
|
# Since jQuery still isn't activating, give up and raise an exception
|
||||||
raise Exception("Exception: WebDriver could not activate jQuery!")
|
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.
|
""" This method uses fancy javascript to highlight an element.
|
||||||
Used during demo_mode.
|
Used during demo_mode.
|
||||||
@Params
|
@Params
|
||||||
selector - the selector of the element to find
|
selector - the selector of the element to find
|
||||||
by - the type of selector to search by (Default: CSS)
|
by - the type of selector to search by (Default: CSS)
|
||||||
loops - # of times to repeat the highlight animation (Default: 4)
|
loops - # of times to repeat the highlight animation
|
||||||
(4 loops is about 0.70 seconds. Your mileage may vary)
|
(Default: 4. Each loop lasts for about 0.18s)
|
||||||
scroll - the option to scroll to the element first (Default: True)
|
scroll - the option to scroll to the element first (Default: True)
|
||||||
"""
|
"""
|
||||||
element = self.find_element(
|
element = self.find_element(
|
||||||
|
@ -302,6 +303,8 @@ class BaseCase(unittest.TestCase):
|
||||||
except Exception:
|
except Exception:
|
||||||
self.activate_jquery()
|
self.activate_jquery()
|
||||||
self.execute_script(script)
|
self.execute_script(script)
|
||||||
|
if self.highlights:
|
||||||
|
loops = self.highlights
|
||||||
loops = int(loops)
|
loops = int(loops)
|
||||||
for n in xrange(loops):
|
for n in xrange(loops):
|
||||||
script = """jQuery('%s').css('box-shadow',
|
script = """jQuery('%s').css('box-shadow',
|
||||||
|
@ -844,6 +847,7 @@ class BaseCase(unittest.TestCase):
|
||||||
self.data = pytest.config.option.data
|
self.data = pytest.config.option.data
|
||||||
self.demo_mode = pytest.config.option.demo_mode
|
self.demo_mode = pytest.config.option.demo_mode
|
||||||
self.demo_sleep = pytest.config.option.demo_sleep
|
self.demo_sleep = pytest.config.option.demo_sleep
|
||||||
|
self.highlights = pytest.config.option.highlights
|
||||||
if self.with_db_reporting:
|
if self.with_db_reporting:
|
||||||
self.execution_guid = str(uuid.uuid4())
|
self.execution_guid = str(uuid.uuid4())
|
||||||
self.testcase_guid = None
|
self.testcase_guid = None
|
||||||
|
|
|
@ -25,6 +25,7 @@ class SeleniumBrowser(Plugin):
|
||||||
self.options.headless -- the option to run headlessly (--headless)
|
self.options.headless -- the option to run headlessly (--headless)
|
||||||
self.options.demo_mode -- the option to slow down Selenium (--demo_mode)
|
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.demo_sleep -- Selenium action delay in DemoMode (--demo_sleep)
|
||||||
|
self.options.highlights -- # of highlight animations shown (--highlights)
|
||||||
"""
|
"""
|
||||||
name = 'selenium' # Usage: --with-selenium
|
name = 'selenium' # Usage: --with-selenium
|
||||||
|
|
||||||
|
@ -64,6 +65,10 @@ class SeleniumBrowser(Plugin):
|
||||||
default=None,
|
default=None,
|
||||||
help="""Setting this overrides the Demo Mode sleep
|
help="""Setting this overrides the Demo Mode sleep
|
||||||
time that happens after browser actions.""")
|
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):
|
def configure(self, options, conf):
|
||||||
super(SeleniumBrowser, self).configure(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.browser = "%s%s" % (self.options.browser, version)
|
||||||
test.test.demo_mode = self.options.demo_mode
|
test.test.demo_mode = self.options.demo_mode
|
||||||
test.test.demo_sleep = self.options.demo_sleep
|
test.test.demo_sleep = self.options.demo_sleep
|
||||||
|
test.test.highlights = self.options.highlights
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print("Error starting/connecting to Selenium:")
|
print("Error starting/connecting to Selenium:")
|
||||||
print(err)
|
print(err)
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -6,7 +6,7 @@ from setuptools import setup, find_packages # noqa
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='seleniumbase',
|
name='seleniumbase',
|
||||||
version='1.2.0',
|
version='1.2.1',
|
||||||
url='http://seleniumbase.com',
|
url='http://seleniumbase.com',
|
||||||
author='Michael Mintz',
|
author='Michael Mintz',
|
||||||
author_email='@mintzworld',
|
author_email='@mintzworld',
|
||||||
|
|
Loading…
Reference in New Issue