import time
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
o=Options(); o.set_preference('dom.webdriver.enabled',False)
d=webdriver.Firefox(options=o)
try:
    d.get('http://127.0.0.1:9999/geetest_page.html'); time.sleep(6)
    d.execute_script("""
      window.__fired=[];
      var b=document.querySelector('.geetest_btn');
      ['mousedown','mouseup','mousemove','pointerdown','pointerup','pointermove','touchstart','touchend','touchmove'].forEach(function(t){b.addEventListener(t,function(e){window.__fired.push(t+'|'+(e.isTrusted?'T':'F'))},{capture:true});});
    """)
    btn=d.find_element(By.CSS_SELECTOR,'.geetest_btn')
    ActionChains(d).move_to_element(btn).click_and_hold().perform(); time.sleep(0.2)
    for i in range(10):
        ActionChains(d).move_by_offset(5,0).perform(); time.sleep(0.05)
    ActionChains(d).release().perform(); time.sleep(1)
    print('fired',d.execute_script('return window.__fired'))
finally: d.quit()
