Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Last active September 23, 2020 19:41
Show Gist options
  • Save PrateekKumarSingh/d11964768a6afc57e1f2ce0014ef9876 to your computer and use it in GitHub Desktop.
Save PrateekKumarSingh/d11964768a6afc57e1f2ce0014ef9876 to your computer and use it in GitHub Desktop.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
url = "https://keytodatascience.com/games"
browser = webdriver.Chrome()
def capture_matrix():
h = {}
for i in range(0,25):
element = browser.find_element_by_id(i)
h[int(element.text)] = element
return h
def click_matrix_buttons(dictionary,start_idx,count):
for i in range(start_idx,count):
dictionary[i].click()
print('Loading the URL...')
browser.get(url)
print('Game Started!')
browser.find_element_by_id('btnRestart').click()
print('Playing...')
click_matrix_buttons(capture_matrix(),1,26)
click_matrix_buttons(capture_matrix(),26,51)
print('Done!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment