Skip to content

Commit 5079d79

Browse files
authored
Merge pull request #154 from seleniumbase/minor-updates
Minor updates
2 parents 5c293a9 + c667bf0 commit 5079d79

File tree

3 files changed

+69
-16
lines changed

3 files changed

+69
-16
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,22 @@ cd SeleniumBase
8888

8989
If you're installing SeleniumBase from a cloned copy on your machine, use:
9090
```
91-
pip install -r requirements.txt
91+
pip install -U -r requirements.txt
9292
9393
python setup.py develop
9494
```
9595

9696
If you're installing SeleniumBase from the [Python Package Index](https://pypi.python.org/pypi/seleniumbase), use:
9797
```bash
98-
pip install seleniumbase
98+
pip install -U seleniumbase
9999
```
100100

101101
If you're installing SeleniumBase directly from GitHub, use:
102102
```bash
103-
pip install -e git+https://github.com/seleniumbase/SeleniumBase.git@master#egg=seleniumbase
103+
pip install -U -e git+https://github.com/seleniumbase/SeleniumBase.git@master#egg=seleniumbase
104104
```
105105

106-
(If you already have an older version installed, you may want to add ``--upgrade`` to your ``pip`` command to update existing Python packages. If you're not using a virtual environment, you may need to add ``--user`` to your ``pip`` command if you're getting errors during installation.)
107-
108-
(If you want to use Python 3.x instead of Python 2.7, use ``pip3`` in place of ``pip`` and ``python3`` in place of ``python``.)
106+
(If you encounter permission errors during installation while not using a virtual environment, you may need to add ``--user`` to your ``pip`` command.)
109107

110108

111109
<a id="seleniumbase_basic_usage"></a>

seleniumbase/fixtures/base_case.py

Lines changed: 64 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,8 @@ def activate_jquery(self):
698698
'''script.src = "http://code.jquery.com/jquery-3.2.1.min.js"; '''
699699
'''document.getElementsByTagName("head")[0]'''
700700
'''.appendChild(script);''')
701-
for x in range(30):
702-
# jQuery needs a small amount of time to activate. (At most 3s)
701+
for x in range(int(settings.MINI_TIMEOUT * 10.0)):
702+
# jQuery needs a small amount of time to activate.
703703
try:
704704
self.execute_script("jQuery('html')")
705705
return
@@ -779,9 +779,12 @@ def highlight(self, selector, by=By.CSS_SELECTOR,
779779
try:
780780
selector = self.convert_to_css_selector(selector, by=by)
781781
except Exception:
782-
# Don't highlight if can't convert to CSS_SELECTOR for jQuery
782+
# Don't highlight if can't convert to CSS_SELECTOR
783783
return
784-
selector = self._make_css_match_first_element_only(selector)
784+
785+
if self.highlights:
786+
loops = self.highlights
787+
loops = int(loops)
785788

786789
o_bs = '' # original_box_shadow
787790
style = element.get_attribute('style')
@@ -792,13 +795,66 @@ def highlight(self, selector, by=By.CSS_SELECTOR,
792795
original_box_shadow = style[box_start:box_end]
793796
o_bs = original_box_shadow
794797

798+
if ":contains" not in selector and ":first" not in selector:
799+
selector = self.jq_format(selector)
800+
self.__highlight_with_js(selector, loops, scroll, o_bs)
801+
else:
802+
selector = self._make_css_match_first_element_only(selector)
803+
selector = self.jq_format(selector)
804+
try:
805+
self.__highlight_with_jquery(selector, loops, scroll, o_bs)
806+
except Exception:
807+
pass # JQuery probably couldn't load. Skip highlighting.
808+
time.sleep(0.065)
809+
810+
def __highlight_with_js(self, selector, loops, scroll, o_bs):
811+
script = ("""document.querySelector('%s').style =
812+
'box-shadow: 0px 0px 6px 6px rgba(128, 128, 128, 0.5)';"""
813+
% selector)
814+
self.execute_script(script)
815+
816+
for n in range(loops):
817+
script = ("""document.querySelector('%s').style =
818+
'box-shadow: 0px 0px 6px 6px rgba(255, 0, 0, 1)';"""
819+
% selector)
820+
self.execute_script(script)
821+
time.sleep(0.02)
822+
script = ("""document.querySelector('%s').style =
823+
'box-shadow: 0px 0px 6px 6px rgba(128, 0, 128, 1)';"""
824+
% selector)
825+
self.execute_script(script)
826+
time.sleep(0.02)
827+
script = ("""document.querySelector('%s').style =
828+
'box-shadow: 0px 0px 6px 6px rgba(0, 0, 255, 1)';"""
829+
% selector)
830+
self.execute_script(script)
831+
time.sleep(0.02)
832+
script = ("""document.querySelector('%s').style =
833+
'box-shadow: 0px 0px 6px 6px rgba(0, 255, 0, 1)';"""
834+
% selector)
835+
self.execute_script(script)
836+
time.sleep(0.02)
837+
script = ("""document.querySelector('%s').style =
838+
'box-shadow: 0px 0px 6px 6px rgba(128, 128, 0, 1)';"""
839+
% selector)
840+
self.execute_script(script)
841+
time.sleep(0.02)
842+
script = ("""document.querySelector('%s').style =
843+
'box-shadow: 0px 0px 6px 6px rgba(128, 0, 128, 1)';"""
844+
% selector)
845+
self.execute_script(script)
846+
time.sleep(0.02)
847+
848+
script = ("""document.querySelector('%s').style =
849+
'box-shadow: %s';"""
850+
% (selector, o_bs))
851+
self.execute_script(script)
852+
853+
def __highlight_with_jquery(self, selector, loops, scroll, o_bs):
795854
script = """jQuery('%s').css('box-shadow',
796855
'0px 0px 6px 6px rgba(128, 128, 128, 0.5)');""" % selector
797856
self.safe_execute_script(script)
798857

799-
if self.highlights:
800-
loops = self.highlights
801-
loops = int(loops)
802858
for n in range(loops):
803859
script = """jQuery('%s').css('box-shadow',
804860
'0px 0px 6px 6px rgba(255, 0, 0, 1)');""" % selector
@@ -827,7 +883,6 @@ def highlight(self, selector, by=By.CSS_SELECTOR,
827883

828884
script = """jQuery('%s').css('box-shadow', '%s');""" % (selector, o_bs)
829885
self.execute_script(script)
830-
time.sleep(0.065)
831886

832887
def scroll_to(self, selector, by=By.CSS_SELECTOR,
833888
timeout=settings.SMALL_TIMEOUT):
@@ -1376,7 +1431,7 @@ def wait_for_ready_state_complete(self, timeout=settings.EXTREME_TIMEOUT):
13761431
timeout = self._get_new_timeout(timeout)
13771432
is_ready = page_actions.wait_for_ready_state_complete(self.driver,
13781433
timeout)
1379-
self.wait_for_angularjs()
1434+
self.wait_for_angularjs(timeout=settings.MINI_TIMEOUT)
13801435
return is_ready
13811436

13821437
def wait_for_angularjs(self, timeout=settings.LARGE_TIMEOUT, **kwargs):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='seleniumbase',
10-
version='1.8.1',
10+
version='1.8.2',
1111
description='Web Automation & Testing Framework - http://seleniumbase.com',
1212
long_description='Web Automation and Testing Framework - seleniumbase.com',
1313
platforms='Mac * Windows * Linux * Docker',

0 commit comments

Comments
 (0)