-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMathBattleSolverPython3.py
40 lines (34 loc) · 1.19 KB
/
MathBattleSolverPython3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from selenium.webdriver import Chrome
GAME_URL = 'https://tbot.xyz/math/#eyJ1IjoyNDUzzU0NjMsIm4iOiJSY...'
WEBDRIVER_PATH = '/home/test/Downloads/chromedriver'
NUMBER_OF_WINS = 5000
browser = Chrome(WEBDRIVER_PATH)
browser.get(GAME_URL)
#Start game
button = browser.find_element_by_id("button_correct")
button.click()
#Play
i =0
while i<NUMBER_OF_WINS:
task_x = int(browser.find_element_by_id("task_x").text.strip())
task_op = browser.find_element_by_id("task_op").text
task_y = int(browser.find_element_by_id("task_y").text.strip())
task_res = int(browser.find_element_by_id("task_res").text.strip())
print ("X:",task_x,"Operator:",task_op,"Y:",task_y,"Result:",task_res)
result = -1
if task_op == "+":
result = task_x + task_y
elif task_op == "/":
result = task_x / task_y
elif task_op == "×":
result = task_x * task_y
elif task_op == "–":
result = task_x - task_y
print(result)
button_wrong = button = browser.find_element_by_id("button_wrong")
button_correct = button = browser.find_element_by_id("button_correct")
if result==task_res:
button_correct.click()
else:
button_wrong.click()
i += 1