Guest User

Untitled

a guest
Nov 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. public static void main(String[] args) throws InterruptedException {
  2. // TODO Auto-generated method stub
  3. System.setProperty("webdriver.chrome.driver", "C://chromedriver.exe");
  4. WebDriver driver = new ChromeDriver();
  5. driver.get("http://www.letskodeit.com/");
  6. Thread.sleep(2000L);
  7. driver.findElement(By.xpath("//div[@class='style-joictyv2']")).click();
  8.  
  9. }
  10.  
  11. public static void closeAd(WebDriver driver){
  12. Wait adWaiter = new FluentWait(driver)
  13. .withTimeout(Duration.ofMinutes(1))
  14. .pollingEvery(Duration.ofSeconds(1))
  15. .ignoring(NoSuchElementException.class);
  16. WebElement closeButton = (WebElement) adWaiter.until(new Function<WebDriver, WebElement>() {
  17. @Override
  18. public WebElement apply(WebDriver o) {
  19. return o.findElement(By.xpath("//div[@role='button'][@title='Back to site']"));
  20. }
  21. });
  22. closeButton.click();
  23. System.out.println("Banner closed..");
  24. }
  25.  
  26. public static void main(String[] args) throws InterruptedException {
  27. System.setProperty("webdriver.chrome.driver", "E:/Dev/WebDrivers/chromedriver.exe");
  28. WebDriver driver1 = new ChromeDriver();
  29. driver1.get("http://www.letskodeit.com/");
  30. closeAd(driver1);
  31. Thread.sleep(10000);
  32. driver1.quit();
  33. }
Add Comment
Please, Sign In to add comment