Skip to content

Commit

Permalink
fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
reteps committed Jun 14, 2017
1 parent 376ff46 commit 2692827
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions grab.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ def start_bot(id,name,answers,speed):
print('Retrying with name set to {}'.format(name))
start_bot(id,name,answers,speed)
elif response == '':
bot_answer(driver,answers)
else:
driver.quit()
speed += 2.5
print('Retrying with speed set to {}'.format(speed))
start_bot(id,name,answers,speed)

bot_answer(driver,answers)
#-------------------------------------------------------------------------#
def bot_answer(driver,answers):
lookuptable = {"0":".answerA", "1":".answerB","2":".answerC","3":".answerD"}
Expand All @@ -65,18 +66,20 @@ def bot_answer(driver,answers):
try:
driver.find_element_by_css_selector(".answer-screen")
if not answered:
print("Chose " + lookup[answers[i]])
try:
driver.find_element_by_css_selector(lookuptable[answers[i]]).click()
print("Chose " + lookup[answers[i]])
except Exception as e:
print('Question was skipped before bot could answer.')
time.sleep(0.5) #prevent doubles
answered, nextQ = False, False
break #next question

answered = True
except Exception as e:
nextQ = True
if nextQ and answered:
nextQ = False
answered = False
nextQ ,answered = False, False
break
time.sleep(0.01)
driver.quit()
Expand Down

0 comments on commit 2692827

Please sign in to comment.