犯罪嫌疑人X
Selenium的当前实现不提供任何执行三次单击的方法。然而,一种可行的方法是使用如下方法模拟所需的鼠标事件:execute_script()def js_triple_click(element, deltaY = 60, offsetX = 0, offsetY = 0): driver.execute_script(""" "var target = arguments[0]; " + "var offsetX = arguments[1]; " + "var offsetY = arguments[2]; " + "var rect = target.getBoundingClientRect(); " + "var cx = rect.left + (offsetX || (rect.width / 2)); " + "var cy = rect.top + (offsetY || (rect.height / 2)); " + " " + "emit('mousedown', {clientX: cx, clientY: cy, buttons: 1}); " + "emit('mouseup', {clientX: cx, clientY: cy}); " + "emit('mousedown', {clientX: cx, clientY: cy, buttons: 1}); " + "emit('mouseup', {clientX: cx, clientY: cy}); " + "emit('mousedown', {clientX: cx, clientY: cy, buttons: 1}); " + "emit('mouseup', {clientX: cx, clientY: cy}); " + "emit('click', {clientX: cx, clientY: cy, detail: 3}); " + " " + "function emit(name, init) { " + "target.dispatchEvent(new MouseEvent(name, init)); " + "} " ; """)element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.TAG_NAME, "p"))) # replace the locator as per your usecaseActionChains(driver).move_to_element(element).perform()js_triple_click(element)print("Tripple click performed")控制台输出:Tripple click performed