from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
browser = webdriver.Chrome()
browser.get('https://gabrielecirulli.github.io/2048/')
try:
while True:
htmlElem = browser.find_element_by_tag_name('body')
time.sleep(0.2)
htmlElem.send_keys(Keys.UP)
time.sleep(0.3)
htmlElem.send_keys(Keys.DOWN)
time.sleep(0.4)
htmlElem.send_keys(Keys.LEFT)
time.sleep(0.5)
htmlElem.send_keys(Keys.RIGHT)
except:
print('Was not able to find an element with that name.')
网友评论