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)
o.set_preference('network.http.referer.spoofSource',True)
o.set_preference('network.http.referer.defaultReferrer','https://ein38eu95792b.4656hd15.cc/')
d=webdriver.Firefox(options=o)
try:
    d.get('http://127.0.0.1:9999/geetest_page.html'); time.sleep(6)
    js="var e=document.querySelector('.geetest_slice');var b=document.querySelector('.geetest_btn');return {sl:e?e.getBoundingClientRect().left:null,bt:b?b.getBoundingClientRect().left:null,st:e?e.getAttribute('style'):null};"
    print('before',d.execute_script(js))
    btn=d.find_element(By.CSS_SELECTOR,'.geetest_btn')
    ActionChains(d).move_to_element(btn).click_and_hold().perform(); time.sleep(0.3)
    print('after hold',d.execute_script(js))
    for i in range(10):
        ActionChains(d).move_by_offset(5,0).perform(); time.sleep(0.05)
    time.sleep(0.3)
    print('after move',d.execute_script(js))
    ActionChains(d).release().perform(); time.sleep(1)
    print('after release',d.execute_script(js))
    print('validate',d.execute_script('return window.validateResult'))
finally: d.quit()
