Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. package org.nutonian;
  2.  
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.TimeoutException;
  5. import org.openqa.selenium.WebDriver;
  6. import org.openqa.selenium.WebElement;
  7. import org.openqa.selenium.remote.DesiredCapabilities;
  8. import org.openqa.selenium.remote.LocalFileDetector;
  9. import org.openqa.selenium.remote.RemoteWebDriver;
  10.  
  11. import java.net.MalformedURLException;
  12. import java.net.URL;
  13. import java.util.concurrent.TimeUnit;
  14.  
  15. public class Selenium2Example {
  16.  
  17. public static void main(String[] args) throws MalformedURLException {
  18. WebDriver driver;
  19.  
  20. System.out.println("Setting up IE");
  21. DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
  22.  
  23. System.out.println("Connecting and opening IE");
  24. driver = new RemoteWebDriver(new URL("http://50.19.191.201:4444/wd/hub"), capabilities);
  25. System.out.println("Done");
  26. ((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector());
  27.  
  28. driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
  29. driver.manage().window().maximize();
  30.  
  31. try {
  32. System.out.println("Connecting to nutonian");
  33. driver.get("https://ptolemy.nutonian.com/login");
  34. System.out.println("Connected!");
  35. } catch (TimeoutException e) {
  36. System.out.println("Caught timeout exception");
  37. }
  38.  
  39. System.out.println("Waiting");
  40. driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  41.  
  42. System.out.println("Getting username");
  43. WebElement userName = driver.findElement(By.name("user_name"));
  44.  
  45. System.out.println("Getting password");
  46. WebElement password = driver.findElement(By.name("pw"));
  47.  
  48. System.out.println("Inputting username");
  49. userName.sendKeys("test@nutonian.com");
  50.  
  51. System.out.println("Inputting password");
  52. password.sendKeys("Password123");
  53.  
  54. try {
  55. password.submit();
  56. } catch (TimeoutException e) {
  57. System.out.println("Caught timeout exception");
  58. }
  59.  
  60. driver.quit();
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement