Skip to content

Instantly share code, notes, and snippets.

@YatinAdityaT
Created June 20, 2020 07:12
Show Gist options
  • Save YatinAdityaT/32b5f822ddbeb59f878d8a4d389dcbe8 to your computer and use it in GitHub Desktop.
Save YatinAdityaT/32b5f822ddbeb59f878d8a4d389dcbe8 to your computer and use it in GitHub Desktop.
selenium dino game
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()
@YatinAdityaT
Copy link
Author

YatinAdityaT commented Jun 20, 2020

download chrome driver from : https://chromedriver.chromium.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment