Last active
November 30, 2019 09:43
-
-
Save vietvudanh/b5f4b8a227bc52f3f62b6c619ca22614 to your computer and use it in GitHub Desktop.
Auto 10fastFinger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""just for fun on 10 fast fin | |
including some random stuff and error to make it more 'human' | |
""" | |
import time | |
import random | |
from selenium.webdriver import Chrome, ChromeOptions | |
WPM = 300 | |
base_interrval = 60 / WPM / 50 # words length + made up for time.sleep(), this should do it | |
error_rate = 1 / 100 | |
print(WPM, base_interrval, error_rate) | |
options = ChromeOptions() | |
driver = Chrome(options=options) | |
driver.get("https://10fastfingers.com/typing-test/english") | |
time.sleep(1) | |
elm_text = driver.find_element_by_id("inputfield") | |
total_stroke = 0 | |
wrong_stroke = 0 | |
start_time = time.time() | |
for i, e in enumerate(driver.find_elements_by_css_selector('#words span')): | |
text = e.get_attribute('innerHTML') | |
for c in text: | |
total_stroke += 1 | |
if random.randint(1, int(1 / error_rate)) == 1: | |
print('fail on purpose') | |
elm_text.send_keys(chr(random.randint(96, 122))) | |
wrong_stroke += 1 | |
break | |
else: | |
elm_text.send_keys(c) | |
time.sleep(base_interrval + random.uniform(base_interrval, base_interrval*2)) | |
elm_text.send_keys(' ') | |
time.sleep(base_interrval + random.uniform(base_interrval, base_interrval*2)) | |
if random.randint(1, 30) == 1: | |
time.sleep(random.uniform(base_interrval * 2, base_interrval * 10)) | |
if (time.time() - start_time) > 60: | |
break | |
print(wrong_stroke, total_stroke) | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment