Hack Forums
[Python] Useless typing test bot - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Useless typing test bot (/showthread.php?tid=5582584)



Useless typing test bot - Ensky - Mar 23, 2017

Someone challenged me to a typing test, so I threw this shitty bot together in about ten minutes.

(runs faster than a Java version for some reason)

[Image: 1a543cbe17ef99112627ebd0225032ba.png]

PHP Code

<?php 
from selenium import webdriver
import time

class Typer:

    
wordsList = []

    
def __init__(self, url:str):
        
self.url = url
        self
.driver = webdriver.Chrome()
        
self.driver.get(url)

        
self.setWords()

    
def setWords(self):
        
''' Scrapes the words on the page so they are in an array to speed things up. '''
        
all_words = self.driver.find_elements_by_xpath('//*[@id="words"]/span')
        for 
word in all_words:
            
self.wordsList.append(word.get_attribute('innerHTML'))

    
def run(self):
        
''' Runs the program '''
        
input = self.driver.find_element_by_id('input')
        for 
w in self.wordsList:
            
input.send_keys(w + " ")

typer = Typer('http://typing-speed-test.aoeu.eu/')
typer.run() 

Needs Chrome Driver in the same directory to run. You can get it from here

https://chromedriver.storage.googleapis.com/index.html?path=2.28/