Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Shitty typing test bot

I'm new to Java, I made a Python version so I thought I'd give it a go in Java too.


Here's it in action (it's slightly slower than the Python version, however.)

[Image: 788dec1e309a896fafe9d6b648903b45.gif]


The code, please criticise me.

PHP Code

<?php 
package typingTest
;

import java.util.List;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class 
TypingBot {
    
    static final 
String URL = "http://typing-speed-test.aoeu.eu/";
    static final 
ChromeDriver DRIVER = new ChromeDriver();
    static List<
WebElement> wordList;
    
    public static 
void main(String[] args) {
        
DRIVER.get(URL);
        
setWordList();
        
run();
    }
    
    
synchronized public static void setWordList() {
        
wordList = DRIVER.findElementsByXPath("//*[@id=\"words\"]/span");
    }
    
    
synchronized public static void run() {
        
WebElement input = DRIVER.findElementById("input");
        for(
WebElement el : wordList) {
            
String word = el.getAttribute("innerHTML") + " ";
            
input.sendKeys(word);
        }
    } 
(Mar 24, 2017 06:14 AM)Owl Wrote:  If you want more of a challenge, recreate the test in Java :)

Good idea :) Will look into it thanks


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by WhiteTiger.Jun 6, 2018 05:57 AM 3 146 Jun 6, 2018 05:57 AM
Last Post: koolkid
[Python] by EnskyMar 23, 2017 01:27 PM 0 172 Mar 23, 2017 01:27 PM
Last Post: Ensky
[Shell] by SkidyMar 20, 2017 01:12 PM 1 113 Mar 20, 2017 01:12 PM
Last Post: OkeFuk