Close popup | Selenium Forum
M
Posted on 04/02/2016
Iam tryong to close the popup came on "makemytrip .com". I am not sure, why getting the exception. I tried with both locators for the "X" button.

//webdriver.findElement(By.cssSelector(".wewidgeticon.we_close.icon-large")).click();
//webdriver.findElement(By.xpath("//*[@id='webklipper-publisher-widget-container-notification-close-div']/span/i"));

Attached the screen for your reference.

M
Replied on 04/02/2016

post relevant part of your code so i can try and run


M
Replied on 05/02/2016

----------------------Here is my code snippet------------

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class MakeMyTrip1 {

public static void main(String[] args) {
WebDriver webdriver = new FirefoxDriver();
webdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
webdriver.get("http://makemytrip.com"); webdriver.findElement(By.cssSelector(".wewidgeticon.we_close.icon-large")).click();
//webdriver.findElement(By.xpath("//*[@id='webklipper-publisher-widget-container-notification-close-div']/span/i"));

/*System.out.println("WINDOW"+webdriver.getWindowHandle());
Set<String> set = webdriver.getWindowHandles();
System.out.println("Count:"+ set.size());
*/
}
}

*************Throwing below exception*********

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"css selector","selector":".wewidgeticon.we_close.icon-large"}
Command duration or timeout: 10.26 seconds


M
Replied on 05/02/2016

use this


[code:31imv7oi]package com.sample;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class MakeMyTrip1 {

public static void main(String[] args) throws InterruptedException {
WebDriver webdriver = new FirefoxDriver();
webdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
webdriver.get("http://makemytrip.com");
Thread.sleep(5000);
webdriver.switchTo().frame("webklipper-publisher-widget-container-notification-frame");

webdriver.findElement(
By.cssSelector(".wewidgeticon.we_close.icon-large")).click();
// webdriver.findElement(By.xpath("//*[@id='webklipper-publisher-widget-container-notification-close-div']/span/i"));

/*
* System.out.println("WINDOW"+webdriver.getWindowHandle()); Set<String>
* set = webdriver.getWindowHandles(); System.out.println("Count:"+
* set.size());
*/
}
}
[/code:31imv7oi]


M
Replied on 06/02/2016

Thanks you soo much. could you please explain in details like , how did you figure it out ifit is a frame ? i tried finding using firebug/source code of the page also , but couldnt get "webklipper-publisher-widget-container-notification-frame" element.
are there any steps we need to consider incase of these types of widgets? Thanks in anticipation.


M
Replied on 07/02/2016

handling of iframes has been explained in the course.