Created
June 20, 2020 07:12
-
-
Save YatinAdityaT/32b5f822ddbeb59f878d8a4d389dcbe8 to your computer and use it in GitHub Desktop.
selenium dino game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
from selenium.common.exceptions import StaleElementReferenceException | |
driver = webdriver.Firefox(executable_path=r'D:\Installers\geckodriver.exe') # path of your geckodriver and change firefox to Chrome.... | |
driver.get('https://chromedino.com/') | |
driver.maximize_window() | |
driver.switch_to.window(driver.current_window_handle) | |
canvas = driver.find_element_by_css_selector('.runner-canvas') | |
main_body = driver.find_element_by_xpath("//html") | |
outer_body = driver.find_element_by_id('aswift_0_expand') | |
def jump(): | |
main_body.send_keys(Keys.SPACE) | |
def pause(): | |
outer_body.click() | |
def start(): | |
canvas.click() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
download chrome driver from : https://chromedriver.chromium.org/