Thursday, June 28, 2012

I HAZ ALL THE VOTES

I'm living in the DC area for the summer and am a huge NBA fan. Not having cable forced me to watch the NBA playoffs on the Internet. The Western Conference Finals were hosted on TNT's website where you could vote for a fan cam to follow a player from each team. I wanted to put two unlikely players on the fan cam so I wrote a little program with the help of Selenium WebDriver to repeatedly vote for me. The expected results were for Tony Parker and Kevin Durant to be the leading vote getters. Instead it was to bench warmers. The script is after the jump.


package Vote;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.By;
import java.net.Socket;

public class voteRunner {
 

    public static void main(String[] args) {
        // Create a new instance of the Firefox driver
        // Notice that the remainder of the code relies on the interface,
        // not the implementation.
        WebDriver driver = new FirefoxDriver();

        driver.get("http://www.tntdrama.com/sports/nba/overtime10_pollH/");
        int i = 0;
        while(i < 10000000)
        {
         driver.get("http://www.tntdrama.com/sports/nba/overtime10_pollA/");
         driver.findElement(By.xpath("(//input[@name='playoffs09_q3_t2'])[4]")).click();
   driver.findElement(By.id("theimagevote")).click();
   i++;
         System.out.println("I is: " + i);
        }
    }
}

No comments:

Post a Comment