-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
30 lines (23 loc) · 803 Bytes
/
main.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
from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from time import sleep
from pynput.keyboard import Controller as KBController
def remove_cookie_modal():
driver.execute_script('return document.querySelector("#qc-cmp2-main").remove()')
kbc = KBController()
driver = Chrome()
driver.get('https://www.typing.com/student/typing-test/1-minute')
remove_cookie_modal()
driver.find_element(By.TAG_NAME, 'body').send_keys('\n')
sleep(0.3)
remove_cookie_modal()
text_input = driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div/div/div[2]/div[2]/div[1]/div/div/div')
typing = True
while typing:
text = text_input.text
text = text.replace('\n', '').replace(' ', ' ')
for c in text:
kbc.tap(c)
sleep(0.1)
sleep(0.1)
driver.quit()