@@ -252,7 +252,9 @@ def open(self, url):
252
252
or "ERR_CONNECTION_RESET" in e.msg
253
253
or "ERR_NAME_NOT_RESOLVED" in e.msg
254
254
):
255
- time.sleep(0.5)
255
+ shared_utils.check_if_time_limit_exceeded()
256
+ self.__check_browser()
257
+ time.sleep(0.8)
256
258
self.driver.get(url)
257
259
elif "Timed out receiving message from renderer" in e.msg:
258
260
page_load_timeout = None
@@ -430,9 +432,11 @@ def click(
430
432
if (
431
433
"element has zero size" in e.msg
432
434
and element.tag_name.lower() == "a"
433
- and ":contains(" not in selector
434
435
):
435
- self.js_click(selector, by=by)
436
+ if "contains(" not in selector:
437
+ self.js_click(selector, by=by)
438
+ else:
439
+ self.jquery_click(selector, by=by)
436
440
return
437
441
except Exception:
438
442
pass
@@ -475,7 +479,7 @@ def click(
475
479
if scroll and not self.demo_mode and not self.slow_mode:
476
480
self.__scroll_to_element(element, selector, by)
477
481
if self.browser == "firefox" or self.browser == "safari":
478
- if by == By.LINK_TEXT or ": contains(" in selector:
482
+ if by == By.LINK_TEXT or "contains(" in selector:
479
483
self.__jquery_click(selector, by=by)
480
484
else:
481
485
self.__js_click(selector, by=by)
@@ -557,7 +561,7 @@ def click(
557
561
self.wait_for_ready_state_complete()
558
562
except Exception:
559
563
pass
560
- if self.__needs_minimum_wait():
564
+ if self.__needs_minimum_wait() or self.browser == "safari" :
561
565
time.sleep(0.05)
562
566
else:
563
567
time.sleep(0.08)
@@ -568,7 +572,7 @@ def click(
568
572
self.wait_for_angularjs(timeout=settings.MINI_TIMEOUT)
569
573
except Exception:
570
574
pass
571
- if self.__needs_minimum_wait():
575
+ if self.__needs_minimum_wait() or self.browser == "safari" :
572
576
time.sleep(0.026)
573
577
try:
574
578
if self.driver.current_url != pre_action_url:
@@ -1172,7 +1176,9 @@ def go_back(self):
1172
1176
self.__extra_actions.append(action)
1173
1177
if self.browser == "safari":
1174
1178
self.wait_for_ready_state_complete()
1179
+ time.sleep(0.02)
1175
1180
self.driver.refresh()
1181
+ time.sleep(0.02)
1176
1182
self.wait_for_ready_state_complete()
1177
1183
self.__demo_mode_pause_if_active()
1178
1184
@@ -1979,7 +1985,7 @@ def click_visible_elements(
1979
1985
If "limit" is set and > 0, will only click that many elements.
1980
1986
Also clicks elements that become visible from previous clicks.
1981
1987
Works best for actions such as clicking all checkboxes on a page.
1982
- Example: self.click_visible_elements('input[type="checkbox"]')"""
1988
+ Example: self.click_visible_elements('input[type="checkbox"]')"""
1983
1989
self.__check_scope()
1984
1990
if not timeout:
1985
1991
timeout = settings.SMALL_TIMEOUT
@@ -2003,30 +2009,6 @@ def click_visible_elements(
2003
2009
except Exception:
2004
2010
pass
2005
2011
elements = self.find_elements(selector, by=by)
2006
- if self.browser == "safari":
2007
- if not limit:
2008
- limit = 0
2009
- num_elements = len(elements)
2010
- if num_elements == 0:
2011
- raise Exception(
2012
- "No matching elements found for selector {%s}!" % selector
2013
- )
2014
- elif num_elements < limit or limit == 0:
2015
- limit = num_elements
2016
- selector, by = self.__recalculate_selector(selector, by)
2017
- css_selector = self.convert_to_css_selector(selector, by=by)
2018
- last_css_chunk = css_selector.split(" ")[-1]
2019
- if ":" in last_css_chunk:
2020
- self.__js_click_all(css_selector)
2021
- self.wait_for_ready_state_complete()
2022
- return
2023
- else:
2024
- for i in range(1, limit + 1):
2025
- new_selector = css_selector + ":nth-of-type(%s)" % str(i)
2026
- if self.is_element_visible(new_selector):
2027
- self.__js_click(new_selector)
2028
- self.wait_for_ready_state_complete()
2029
- return
2030
2012
pre_action_url = self.driver.current_url
2031
2013
pre_window_count = len(self.driver.window_handles)
2032
2014
click_count = 0
@@ -2081,7 +2063,7 @@ def click_nth_visible_element(
2081
2063
self, selector, number, by="css selector", timeout=None
2082
2064
):
2083
2065
"""Finds all matching page elements and clicks the nth visible one.
2084
- Example: self.click_nth_visible_element('[type="checkbox"]', 5)
2066
+ Example: self.click_nth_visible_element('[type="checkbox"]', 5)
2085
2067
(Clicks the 5th visible checkbox on the page.)"""
2086
2068
self.__check_scope()
2087
2069
if not timeout:
@@ -12689,7 +12671,10 @@ def __highlight_with_assert_success(
12689
12671
time.sleep(0.065)
12690
12672
12691
12673
def __activate_virtual_display_as_needed(self):
12692
- if self.headless or self.headless2 or self.xvfb:
12674
+ """Should be needed only on Linux.
12675
+ The "--xvfb" arg is still useful, as it prevents headless mode,
12676
+ which is the default mode on Linux unless using another arg."""
12677
+ if "linux" in sys.platform:
12693
12678
width = settings.HEADLESS_START_WIDTH
12694
12679
height = settings.HEADLESS_START_HEIGHT
12695
12680
try:
@@ -13508,7 +13493,7 @@ def setUp(self, masterqa_mode=False):
13508
13493
elif hasattr(self, "is_nosetest") and self.is_nosetest:
13509
13494
pass # Setup performed in plugins for nosetests
13510
13495
else:
13511
- # Pure Python run
13496
+ # Pure Python run. Eg. SB() Manager
13512
13497
self.__activate_virtual_display_as_needed()
13513
13498
13514
13499
# Verify that SeleniumBase is installed successfully
0 commit comments