Advertisement
Guest User

Untitled

a guest
Sep 30th, 2013
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1.  
  2.  
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebDriver;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.htmlunit.HtmlUnitDriver;
  7. import org.openqa.selenium.phantomjs.PhantomJSDriver;
  8. import org.openqa.selenium.remote.DesiredCapabilities;
  9.  
  10. public class testing  {
  11.     public static void main(String[] args) throws InterruptedException {
  12.        
  13.         System.setProperty("phantomjs.binary.path", "../Third Party Libraries/phantomjs-1.9.2-windows/phantomjs.exe");
  14.        
  15.         DesiredCapabilities dCaps;
  16.         dCaps = new DesiredCapabilities();
  17.         dCaps.setJavascriptEnabled(true);
  18.         dCaps.setCapability("takesScreenshot", false);
  19.         WebDriver driver = new PhantomJSDriver(dCaps);
  20.        
  21.      System.out.println("Page title is: " + driver.getTitle());
  22.         driver.get("http://www.twitch.tv/login");
  23.      System.out.println("Page title is: " + driver.getTitle());
  24.         WebElement element = driver.findElement(By.id("login_user_login"));
  25.  
  26.         element.sendKeys("username");
  27.  
  28.         WebElement element2 = driver.findElement(By.id("user[password]"));
  29.         element2.sendKeys("password");
  30.        
  31.        element2.submit();Thread.sleep(3000);
  32.         System.out.println("Page title is: " + driver.getTitle());Thread.sleep(3000);
  33.         driver.get("http://www.twitch.tv/mradder89/profile/following");Thread.sleep(3000);
  34.         driver.findElement(By.xpath("//span[@id='ember637']/a/span")).click();
  35.  
  36.         System.out.println("Page title is: " + driver.getTitle());
  37.         System.out.println("done");
  38.         driver.quit();
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement