Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws InterruptedException {
- // TODO Auto-generated method stub
- System.setProperty("webdriver.chrome.driver", "C://chromedriver.exe");
- WebDriver driver = new ChromeDriver();
- driver.get("http://www.letskodeit.com/");
- Thread.sleep(2000L);
- driver.findElement(By.xpath("//div[@class='style-joictyv2']")).click();
- }
- public static void closeAd(WebDriver driver){
- Wait adWaiter = new FluentWait(driver)
- .withTimeout(Duration.ofMinutes(1))
- .pollingEvery(Duration.ofSeconds(1))
- .ignoring(NoSuchElementException.class);
- WebElement closeButton = (WebElement) adWaiter.until(new Function<WebDriver, WebElement>() {
- @Override
- public WebElement apply(WebDriver o) {
- return o.findElement(By.xpath("//div[@role='button'][@title='Back to site']"));
- }
- });
- closeButton.click();
- System.out.println("Banner closed..");
- }
- public static void main(String[] args) throws InterruptedException {
- System.setProperty("webdriver.chrome.driver", "E:/Dev/WebDrivers/chromedriver.exe");
- WebDriver driver1 = new ChromeDriver();
- driver1.get("http://www.letskodeit.com/");
- closeAd(driver1);
- Thread.sleep(10000);
- driver1.quit();
- }
Add Comment
Please, Sign In to add comment