Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.nutonian;
- import org.openqa.selenium.By;
- import org.openqa.selenium.TimeoutException;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.remote.DesiredCapabilities;
- import org.openqa.selenium.remote.LocalFileDetector;
- import org.openqa.selenium.remote.RemoteWebDriver;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.concurrent.TimeUnit;
- public class Selenium2Example {
- public static void main(String[] args) throws MalformedURLException {
- WebDriver driver;
- System.out.println("Setting up IE");
- DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
- System.out.println("Connecting and opening IE");
- driver = new RemoteWebDriver(new URL("http://50.19.191.201:4444/wd/hub"), capabilities);
- System.out.println("Done");
- ((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector());
- driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
- driver.manage().window().maximize();
- try {
- System.out.println("Connecting to nutonian");
- driver.get("https://ptolemy.nutonian.com/login");
- System.out.println("Connected!");
- } catch (TimeoutException e) {
- System.out.println("Caught timeout exception");
- }
- System.out.println("Waiting");
- driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
- System.out.println("Getting username");
- WebElement userName = driver.findElement(By.name("user_name"));
- System.out.println("Getting password");
- WebElement password = driver.findElement(By.name("pw"));
- System.out.println("Inputting username");
- userName.sendKeys("test@nutonian.com");
- System.out.println("Inputting password");
- password.sendKeys("Password123");
- try {
- password.submit();
- } catch (TimeoutException e) {
- System.out.println("Caught timeout exception");
- }
- driver.quit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement