Skip to content

Commit fa2173e

Browse files
authored
Update PyTypeRacer.py
Fixed some bugs
1 parent efdaf8f commit fa2173e

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

PyTypeRacer.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,19 @@ def main():
8585

8686
word_check = (word1 + wordcomma + ' ' + word2)
8787
word_complete = re.sub(' , ', ', ', word_check)
88+
allow_print = True
8889
clear()
8990
print('Words: \n' + word_complete + '\n')
9091
for char in word_complete:
9192
wpm = re.sub(' wpm', '', browser.find_element_by_xpath('//*[@class="rankPanelWpm rankPanelWpm-self"]').text)
9293
if int(wpm) >= max_wpm:
94+
if allow_print == True:
95+
print(f'WPM limit threshold: {wpm}/{max_wpm}')
96+
allow_print = False
9397
typeBar.send_keys(char)
9498
time.sleep(0.2)
9599
else:
100+
allow_print = True
96101
typeBar.send_keys(char)
97102
time.sleep(delay)
98103
loop()
@@ -103,14 +108,19 @@ def main():
103108

104109
word_check = (word1 + ' ' + word2)
105110
word_complete = re.sub(' , ', ', ', word_check)
111+
allow_print = True
106112
clear()
107113
print('Words: \n' + word_complete + '\n')
108114
for char in word_complete:
109115
wpm = re.sub(' wpm', '', browser.find_element_by_xpath('//*[@class="rankPanelWpm rankPanelWpm-self"]').text)
110116
if int(wpm) >= max_wpm:
117+
if allow_print == True:
118+
print(f'WPM limit threshold: {wpm}/{max_wpm}')
119+
allow_print = False
111120
typeBar.send_keys(char)
112121
time.sleep(0.2)
113122
else:
123+
allow_print = True
114124
typeBar.send_keys(char)
115125
time.sleep(delay)
116126
typeBar.send_keys(char)
@@ -134,10 +144,10 @@ def loopMain():
134144
time.sleep(3)
135145
start()
136146
except:
137-
browser.find_element_by_link_text('Race Again »').click()
147+
browser.find_element_by_xpath('//*[@class="raceAgainLink"]').click()
138148
time.sleep(1)
139149
try:
140-
browser.find_element_by_link_text('No thanks :(').click()
150+
browser.find_element_by_xpath('//*[@class="xButton"]').click()
141151
time.sleep(3)
142152
start()
143153
except:
@@ -149,10 +159,10 @@ def loopMain():
149159
time.sleep(3)
150160
start()
151161
except:
152-
browser.find_element_by_link_text('Race Again »').click()
162+
browser.find_element_by_xpath('//*[@class="raceAgainLink"]').click()
153163
time.sleep(1)
154164
try:
155-
browser.find_element_by_link_text('No thanks :(').click()
165+
browser.find_element_by_xpath('//*[@class="xButton"]').click()
156166
time.sleep(3)
157167
start()
158168
except:
@@ -196,10 +206,10 @@ def login():
196206
clear()
197207
print('You need to wait for the site to finish loading!!!\nExiting program!')
198208
time.sleep(3)
199-
time.sleep(0.5)
209+
time.sleep(1.5)
200210
browser.find_element_by_link_text('change display format').click()
201-
time.sleep(0.5)
211+
time.sleep(1.5)
202212
browser.find_element_by_xpath('(//*[@type="radio"])[2]').click()
203-
time.sleep(0.5)
213+
time.sleep(1.5)
204214
browser.find_element_by_xpath('//*[@title="close this popup"]').click()
205215
start()

0 commit comments

Comments
 (0)