Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Auto play script for eYenurse game (http://m.xiaoxineye.com/wxaward/html5/games/eye/index.html). Work with Safari on Mac.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Safari()
browser.set_window_size(1024, 768)
browser.get('http://m.xiaoxineye.com/wxaward/html5/games/eye/index.html')
# Game start
start_btn = browser.find_element_by_css_selector('button')
start_btn.send_keys(Keys.RETURN)
while True:
color_box = browser.find_element_by_xpath('//div[@id="box"]')
if not color_box:
print("No more boxes.")
break
box_list = color_box.find_elements_by_xpath('./span')
color_num_dict = {}
target_box_dict = {}
for index, box in enumerate(box_list):
color = box.get_attribute('style')
if color_num_dict.get(color):
color_num_dict[color] += 1
if len(color_num_dict.keys()) == 2 and color_num_dict[color] >= 2:
break
else:
color_num_dict[color] = 1
target_box_dict[color] = box
target_box = None
for key in color_num_dict.keys():
if color_num_dict[key] == 1:
target_box = target_box_dict[key]
if not target_box:
break
target_box.click()
certifi==2019.3.9
selenium==3.141.0
urllib3==1.25.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.