Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. package pl.patryk;
  2.  
  3. import java.util.concurrent.TimeUnit;
  4.  
  5. import org.openqa.selenium.By;
  6. import org.openqa.selenium.By.ByTagName;
  7. import org.openqa.selenium.WebDriver;
  8. import org.openqa.selenium.WebElement;
  9. import org.openqa.selenium.chrome.ChromeDriver;
  10. import org.openqa.selenium.support.ui.WebDriverWait;
  11.  
  12. public class Bot {
  13.  
  14.     public static void main(String[] args) {
  15.         WebDriver driver = new ChromeDriver();
  16.  
  17.         driver.get("https://lobby.ikariam.gameforge.com/pl_PL/");
  18.  
  19.         new WebDriverWait(driver, 1);
  20.        
  21.         WebElement elementEmail = driver.findElement(By.name("email"));
  22.         WebElement element2 = driver.findElement(By.name("password"));
  23.         elementEmail.sendKeys("@gmail.com");
  24.         element2.sendKeys("password");
  25.        
  26.         driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
  27.  
  28.         element2.submit();
  29.         driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
  30.        
  31.         WebElement element3 = driver.findElement(By.name("password"));
  32.         element3.submit();
  33.        
  34.        
  35.         System.out.println("Page title is: " + driver.getTitle());
  36.         // Google's search is rendered dynamically with JavaScript.
  37.         // Wait for the page to load, timeout after 10 seconds
  38.         /*
  39.          * (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
  40.          * public Boolean apply(WebDriver d) { return
  41.          * d.getTitle().toLowerCase().startsWith("cheese!"); } });
  42.          */
  43.         // Should see: "cheese! - Google Search"
  44.         System.out.println("Page title is: " + driver.getTitle());
  45.        
  46.         // driver.quit();
  47.     }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement