Skip to content

Commit 700f291

Browse files
committed
Improve mobile compatibility
1 parent 63c55a8 commit 700f291

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,10 +1190,14 @@ def hover_and_click(self, hover_selector, click_selector,
11901190
outdated_driver = False
11911191
element = None
11921192
try:
1193-
if self.browser == "safari":
1193+
if self.mobile_emulator:
1194+
# On mobile, click to hover the element
1195+
dropdown_element.click()
1196+
elif self.browser == "safari":
11941197
# Use the workaround for hover-clicking on Safari
11951198
raise Exception("This Exception will be caught.")
1196-
page_actions.hover_element(self.driver, dropdown_element)
1199+
else:
1200+
page_actions.hover_element(self.driver, dropdown_element)
11971201
except Exception:
11981202
outdated_driver = True
11991203
element = self.wait_for_element_present(
@@ -1204,8 +1208,12 @@ def hover_and_click(self, hover_selector, click_selector,
12041208
self.open(self.__get_href_from_partial_link_text(
12051209
click_selector))
12061210
else:
1207-
self.js_click(click_selector, click_by)
1208-
if not outdated_driver:
1211+
self.js_click(click_selector, by=click_by)
1212+
if outdated_driver:
1213+
pass # Already did the click workaround
1214+
elif self.mobile_emulator:
1215+
self.click(click_selector, by=click_by)
1216+
elif not outdated_driver:
12091217
element = page_actions.hover_and_click(
12101218
self.driver, hover_selector, click_selector,
12111219
hover_by, click_by, timeout)
@@ -5137,6 +5145,11 @@ def setUp(self, masterqa_mode=False):
51375145
if self._reuse_session:
51385146
sb_config.shared_driver = self.driver
51395147

5148+
if self.browser in ["firefox", "ie", "safari"]:
5149+
# Only Chromium-based browsers have the mobile emulator.
5150+
# Some actions such as hover-clicking are different on mobile.
5151+
self.mobile_emulator = False
5152+
51405153
# Configure the test time limit (if used).
51415154
self.set_time_limit(self.time_limit)
51425155

0 commit comments

Comments
 (0)