码迷,mamicode.com
首页 > 编程语言 > 详细

python编程快速上手之第10章实践项目参考答案(11.11.3)

时间:2017-05-09 00:49:27      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:blog   imp   pre   common   new   abr   ext   参考答案   row   

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
browser = webdriver.Firefox()
url = https://gabrielecirulli.github.io/2048/
browser.get(url)
game_ele = browser.find_element_by_class_name(game-container)
while True:
    retry_ele = browser.find_element_by_class_name(retry-button)
    # new game
    if retry_ele.text == Try again:
        retry_ele.click()
        game_ele = browser.find_element_by_class_name(game-container)
    game_ele.send_keys(Keys.UP)
    game_ele.send_keys(Keys.RIGHT)
    game_ele.send_keys(Keys.DOWN)
    game_ele.send_keys(Keys.LEFT)

 

python编程快速上手之第10章实践项目参考答案(11.11.3)

标签:blog   imp   pre   common   new   abr   ext   参考答案   row   

原文地址:http://www.cnblogs.com/flying-wyf/p/6828240.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!