Skip to content

Instantly share code, notes, and snippets.

@santiycr
Created March 11, 2011 23:15
Show Gist options
  • Save santiycr/866785 to your computer and use it in GitHub Desktop.
Save santiycr/866785 to your computer and use it in GitHub Desktop.
Tweet about #SeleniumConf!
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
public class Tweet {
public static void goTweet() throws Exception {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("http://twitter.com");
driver.findElement(By.id("username")).sendKeys("<user>");
driver.findElement(By.id("password")).sendKeys("<pass>");
driver.findElement(By.id("signin_submit")).submit();
driver.findElement(By.xpath("//textarea")).sendKeys("#SeleniumConf is awesome!");
driver.findElement(By.linkText("Tweet")).click();
driver.close();
}
public static void main(String[] args) throws Exception {
goTweet();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment