@@ -406,7 +406,11 @@ def click(
406
406
self.__demo_mode_highlight_if_active(original_selector, original_by)
407
407
if scroll and not self.demo_mode and not self.slow_mode:
408
408
self.__scroll_to_element(element, selector, by)
409
- pre_action_url = self.driver.current_url
409
+ pre_action_url = None
410
+ try:
411
+ pre_action_url = self.driver.current_url
412
+ except Exception:
413
+ pass
410
414
pre_window_count = len(self.driver.window_handles)
411
415
try:
412
416
if (
@@ -707,7 +711,11 @@ def double_click(self, selector, by="css selector", timeout=None):
707
711
timeout=timeout,
708
712
original_selector=original_selector,
709
713
)
710
- pre_action_url = self.driver.current_url
714
+ pre_action_url = None
715
+ try:
716
+ pre_action_url = self.driver.current_url
717
+ except Exception:
718
+ pass
711
719
try:
712
720
if self.browser == "safari":
713
721
# Jump to the "except" block where the other script should work
@@ -788,7 +796,11 @@ def context_click(self, selector, by="css selector", timeout=None):
788
796
timeout=timeout,
789
797
original_selector=original_selector,
790
798
)
791
- pre_action_url = self.driver.current_url
799
+ pre_action_url = None
800
+ try:
801
+ pre_action_url = self.driver.current_url
802
+ except Exception:
803
+ pass
792
804
try:
793
805
if self.browser == "safari":
794
806
# Jump to the "except" block where the other script should work
@@ -913,7 +925,12 @@ def update_text(
913
925
except Exception:
914
926
pass # Clearing the text field first might not be necessary
915
927
self.__demo_mode_pause_if_active(tiny=True)
916
- pre_action_url = self.driver.current_url
928
+ pre_action_url = None
929
+ if self.demo_mode:
930
+ try:
931
+ pre_action_url = self.driver.current_url
932
+ except Exception:
933
+ pass
917
934
text = self.__get_type_checked_text(text)
918
935
try:
919
936
if not text.endswith("\n"):
@@ -1011,7 +1028,12 @@ def add_text(self, selector, text, by="css selector", timeout=None):
1011
1028
self.__demo_mode_highlight_if_active(selector, by)
1012
1029
if not self.demo_mode and not self.slow_mode:
1013
1030
self.__scroll_to_element(element, selector, by)
1014
- pre_action_url = self.driver.current_url
1031
+ pre_action_url = None
1032
+ if self.demo_mode:
1033
+ try:
1034
+ pre_action_url = self.driver.current_url
1035
+ except Exception:
1036
+ pass
1015
1037
text = self.__get_type_checked_text(text)
1016
1038
try:
1017
1039
if not text.endswith("\n"):
@@ -1266,11 +1288,18 @@ def go_back(self):
1266
1288
self.__check_scope()
1267
1289
if hasattr(self, "recorder_mode") and self.recorder_mode:
1268
1290
self.save_recorded_actions()
1269
- pre_action_url = self.driver.current_url
1291
+ pre_action_url = None
1292
+ try:
1293
+ pre_action_url = self.driver.current_url
1294
+ except Exception:
1295
+ pass
1270
1296
self.__last_page_load_url = None
1271
1297
self.driver.back()
1272
- if pre_action_url == self.driver.current_url:
1273
- self.driver.back() # Again because the page was redirected
1298
+ try:
1299
+ if pre_action_url == self.driver.current_url:
1300
+ self.driver.back() # Again because the page was redirected
1301
+ except Exception:
1302
+ pass
1274
1303
if self.recorder_mode:
1275
1304
time_stamp = self.execute_script("return Date.now();")
1276
1305
origin = self.get_origin()
@@ -1529,8 +1558,6 @@ def click_link_text(self, link_text, timeout=None):
1529
1558
timeout = settings.SMALL_TIMEOUT
1530
1559
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
1531
1560
timeout = self.__get_new_timeout(timeout)
1532
- pre_action_url = self.driver.current_url
1533
- pre_window_count = len(self.driver.window_handles)
1534
1561
link_text = self.__get_type_checked_text(link_text)
1535
1562
if self.browser == "safari":
1536
1563
if self.demo_mode:
@@ -1558,7 +1585,12 @@ def click_link_text(self, link_text, timeout=None):
1558
1585
return
1559
1586
if not self.is_link_text_present(link_text):
1560
1587
self.wait_for_link_text_present(link_text, timeout=timeout)
1561
- pre_action_url = self.driver.current_url
1588
+ pre_action_url = None
1589
+ try:
1590
+ pre_action_url = self.driver.current_url
1591
+ except Exception:
1592
+ pass
1593
+ pre_window_count = len(self.driver.window_handles)
1562
1594
try:
1563
1595
element = self.wait_for_link_text_visible(link_text, timeout=0.2)
1564
1596
self.__demo_mode_highlight_if_active(link_text, by="link text")
@@ -1654,7 +1686,11 @@ def click_partial_link_text(self, partial_link_text, timeout=None):
1654
1686
self.wait_for_partial_link_text_present(
1655
1687
partial_link_text, timeout=timeout
1656
1688
)
1657
- pre_action_url = self.driver.current_url
1689
+ pre_action_url = None
1690
+ try:
1691
+ pre_action_url = self.driver.current_url
1692
+ except Exception:
1693
+ pass
1658
1694
pre_window_count = len(self.driver.window_handles)
1659
1695
try:
1660
1696
element = self.wait_for_partial_link_text(
@@ -2125,7 +2161,11 @@ def click_visible_elements(
2125
2161
except Exception:
2126
2162
pass
2127
2163
elements = self.find_elements(selector, by=by)
2128
- pre_action_url = self.driver.current_url
2164
+ pre_action_url = None
2165
+ try:
2166
+ pre_action_url = self.driver.current_url
2167
+ except Exception:
2168
+ pass
2129
2169
pre_window_count = len(self.driver.window_handles)
2130
2170
click_count = 0
2131
2171
for element in elements:
@@ -2207,7 +2247,11 @@ def click_nth_visible_element(
2207
2247
if number < 0:
2208
2248
number = 0
2209
2249
element = elements[number]
2210
- pre_action_url = self.driver.current_url
2250
+ pre_action_url = None
2251
+ try:
2252
+ pre_action_url = self.driver.current_url
2253
+ except Exception:
2254
+ pass
2211
2255
pre_window_count = len(self.driver.window_handles)
2212
2256
try:
2213
2257
self.__scroll_to_element(element)
@@ -2261,7 +2305,11 @@ def click_if_visible(self, selector, by="css selector", timeout=0):
2261
2305
2262
2306
def click_active_element(self):
2263
2307
self.wait_for_ready_state_complete()
2264
- pre_action_url = self.driver.current_url
2308
+ pre_action_url = None
2309
+ try:
2310
+ pre_action_url = self.driver.current_url
2311
+ except Exception:
2312
+ pass
2265
2313
pre_window_count = len(self.driver.window_handles)
2266
2314
if self.recorder_mode:
2267
2315
selector = js_utils.get_active_element_css(self.driver)
@@ -2593,7 +2641,11 @@ def hover_and_click(
2593
2641
)
2594
2642
self.__demo_mode_highlight_if_active(original_selector, original_by)
2595
2643
self.scroll_to(hover_selector, by=hover_by)
2596
- pre_action_url = self.driver.current_url
2644
+ pre_action_url = None
2645
+ try:
2646
+ pre_action_url = self.driver.current_url
2647
+ except Exception:
2648
+ pass
2597
2649
pre_window_count = len(self.driver.window_handles)
2598
2650
if self.recorder_mode and self.__current_url_is_recordable():
2599
2651
if self.get_session_storage_item("pause_recorder") == "no":
@@ -2719,7 +2771,11 @@ def hover_and_double_click(
2719
2771
)
2720
2772
self.__demo_mode_highlight_if_active(original_selector, original_by)
2721
2773
self.scroll_to(hover_selector, by=hover_by)
2722
- pre_action_url = self.driver.current_url
2774
+ pre_action_url = None
2775
+ try:
2776
+ pre_action_url = self.driver.current_url
2777
+ except Exception:
2778
+ pass
2723
2779
pre_window_count = len(self.driver.window_handles)
2724
2780
outdated_driver = False
2725
2781
element = None
@@ -2906,7 +2962,11 @@ def __select_option(
2906
2962
self.__demo_mode_highlight_if_active(
2907
2963
dropdown_selector, dropdown_by
2908
2964
)
2909
- pre_action_url = self.driver.current_url
2965
+ pre_action_url = None
2966
+ try:
2967
+ pre_action_url = self.driver.current_url
2968
+ except Exception:
2969
+ pass
2910
2970
pre_window_count = len(self.driver.window_handles)
2911
2971
try:
2912
2972
if option_by == "index":
@@ -5802,7 +5862,11 @@ def js_click(
5802
5862
css_selector = self.__escape_quotes_if_needed(css_selector)
5803
5863
time_stamp = 0
5804
5864
action = ["", "", "", time_stamp]
5805
- pre_action_url = self.driver.current_url
5865
+ pre_action_url = None
5866
+ try:
5867
+ pre_action_url = self.driver.current_url
5868
+ except Exception:
5869
+ pass
5806
5870
pre_window_count = len(self.driver.window_handles)
5807
5871
if self.recorder_mode and not self.__dont_record_js_click:
5808
5872
time_stamp = self.execute_script("return Date.now();")
@@ -6684,7 +6748,12 @@ def choose_file(
6684
6748
self.__demo_mode_highlight_if_active(selector, by)
6685
6749
if not self.demo_mode and not self.slow_mode:
6686
6750
self.__scroll_to_element(element, selector, by)
6687
- pre_action_url = self.driver.current_url
6751
+ pre_action_url = None
6752
+ if self.demo_mode:
6753
+ try:
6754
+ pre_action_url = self.driver.current_url
6755
+ except Exception:
6756
+ pass
6688
6757
if self.recorder_mode and self.__current_url_is_recordable():
6689
6758
if self.get_session_storage_item("pause_recorder") == "no":
6690
6759
time_stamp = self.execute_script("return Date.now();")
0 commit comments