Skip to content

Commit c4dd428

Browse files
committed
Improve logging from --debug
1 parent dd03551 commit c4dd428

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

seleniumbase/core/sb_cdp.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,16 @@ def gui_click_with_offset(
18031803
def click_with_offset(self, selector, x, y, center=False):
18041804
element = self.find_element(selector)
18051805
element.scroll_into_view()
1806+
if "--debug" in sys.argv:
1807+
displayed_selector = "`%s`" % selector
1808+
if '"' not in selector:
1809+
displayed_selector = '"%s"' % selector
1810+
elif "'" not in selector:
1811+
displayed_selector = "'%s'" % selector
1812+
print(
1813+
" <DEBUG> sb.click_with_offset(%s, %s, %s, center=%s)"
1814+
% (displayed_selector, x, y, center)
1815+
)
18061816
element.click_with_offset(x=x, y=y, center=center)
18071817
self.__slow_mode_pause_if_set()
18081818
self.loop.run_until_complete(self.page.wait())
@@ -2078,13 +2088,17 @@ def __gui_drag_drop(self, x1, y1, x2, y2, timeframe=0.25, uc_lock=False):
20782088
if uc_lock:
20792089
gui_lock = FileLock(constants.MultiBrowser.PYAUTOGUILOCK)
20802090
with gui_lock: # Prevent issues with multiple processes
2091+
if "--debug" in sys.argv:
2092+
print(" <DEBUG> pyautogui.moveTo(%s, %s)" % (x1, y1))
20812093
pyautogui.moveTo(x1, y1, 0.25, pyautogui.easeOutQuad)
20822094
self.__add_light_pause()
20832095
if "--debug" in sys.argv:
2084-
print(" <DEBUG> pyautogui.moveTo(%s, %s)" % (x1, y1))
2096+
print(" <DEBUG> pyautogui.dragTo(%s, %s)" % (x2, y2))
20852097
pyautogui.dragTo(x2, y2, button="left", duration=timeframe)
20862098
else:
20872099
# Called from a method where the gui_lock is already active
2100+
if "--debug" in sys.argv:
2101+
print(" <DEBUG> pyautogui.moveTo(%s, %s)" % (x1, y1))
20882102
pyautogui.moveTo(x1, y1, 0.25, pyautogui.easeOutQuad)
20892103
self.__add_light_pause()
20902104
if "--debug" in sys.argv:
@@ -2163,16 +2177,16 @@ def __gui_hover_x_y(self, x, y, timeframe=0.25, uc_lock=False):
21632177
if uc_lock:
21642178
gui_lock = FileLock(constants.MultiBrowser.PYAUTOGUILOCK)
21652179
with gui_lock: # Prevent issues with multiple processes
2166-
pyautogui.moveTo(x, y, timeframe, pyautogui.easeOutQuad)
2167-
time.sleep(0.056)
21682180
if "--debug" in sys.argv:
21692181
print(" <DEBUG> pyautogui.moveTo(%s, %s)" % (x, y))
2182+
pyautogui.moveTo(x, y, timeframe, pyautogui.easeOutQuad)
2183+
time.sleep(0.056)
21702184
else:
21712185
# Called from a method where the gui_lock is already active
2172-
pyautogui.moveTo(x, y, timeframe, pyautogui.easeOutQuad)
2173-
time.sleep(0.056)
21742186
if "--debug" in sys.argv:
21752187
print(" <DEBUG> pyautogui.moveTo(%s, %s)" % (x, y))
2188+
pyautogui.moveTo(x, y, timeframe, pyautogui.easeOutQuad)
2189+
time.sleep(0.056)
21762190

21772191
def gui_hover_x_y(self, x, y, timeframe=0.25):
21782192
gui_lock = FileLock(constants.MultiBrowser.PYAUTOGUILOCK)

0 commit comments

Comments
 (0)