0

I am doing my work on java Selenium WebDriver. I want to handle frame and multiple popup windows on the same web page?

I have done with handle the frame and going back to default Content. Now I am facing problem in handle multiple popup windows on the same web page?

I have tried with following methods:

//First method

WebDriverWait wait =   new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(By.id("masterPOP")));
driver.findElement(By.id("close-popup")).click();

//Another method

Alert alert = driver.switchTo().alert();
alert.dismiss();

//I am sharing my code below:

package BRA_product;


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

public class frameeeeeee {

    public static void main(String[] args) throws InterruptedException {

        String exePathGecko=("C:\\Users\\Prerna\\Downloads\\geckodriver.exe");
        System.setProperty("webdriver.gecko.driver",exePathGecko);

      WebDriver driver=new FirefoxDriver();
       //Zivame home page
     driver.get("http://www.zivame.com/#?");

     //switch to frame
       driver.switchTo().frame("webpush-bubble"); 
       driver.findElement(By.xpath(".//*[@id='deny']")).click();
       //back to home page
       driver.switchTo().defaultContent();

       //login to zivame 
       driver.findElement(By.xpath("//a[@href='#myaccount']")).click();

       driver.findElement(By.xpath("//*[@id='auth-email']")).sendKeys("test890@gmail.com");

       driver.findElement(By.xpath(".//*[@id='auth-password']")).sendKeys("test123");


       driver.findElement(By.xpath(".//*[@id='authForm']/div[3]/button")).click();



       //Thread.sleep(3000);

       driver.quit();

    }

}

EDIT: Error which i got is:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[@id='auth-email']  

I am getting this error because not able to close two popup on the same page. popup id is :<id=materPOP> and <p id ="close-pop">.

Another popup id details are: <div class="wrapper"> and <div id ="webklipper-publisher-widget-container-notification-close-d‌​iv" class="close">

Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65
prerna
  • 1
  • 2
  • what is the actual issue? what line you facing exception? – Naveen Kumar R B Feb 13 '17 at 10:14
  • I want to move from home page to login.I am facing error at login to zivame. Error which i got is Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[@id='auth-email'] .I am getting this error because not able to close two popup on the same page. popup id is : and

    . Another popup id details are:

    and
    . i hope above information will help you.
    – prerna Feb 13 '17 at 11:53
  • First, identify the `close` buttons of `all Pop-up presents in the Page`, close them by clicking on Close button, then try to find `auth-email`. Also, look if the web elements (either Pop-up close button or email_input) are present inside an `iframe` tag. If yes, first switch to the frame and then find the element. pls have a look at my detailed answer here about the frames http://stackoverflow.com/a/40759300/2575259 – Naveen Kumar R B Feb 13 '17 at 12:05
  • @ naveen , i found the xpath of the java script pop. xpath is .//*[@id='close-popup']/span. i have tried with : Alert alert=driver.switchTo().alert(); WebDriverWait wait = new WebDriverWait(driver, 100); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//*[@id='close-popup']/span")));System.out.println("alert"); alert.dismiss(); driver.switchTo().defaultContent(); – prerna Feb 14 '17 at 20:14
  • @naveen plz help me to solve the above problem – prerna Feb 14 '17 at 20:21
  • Popup and Alert are two different things. Please check which one you are interacting with. 1 Pop-up normally contains many input fields (like login form etc) 2. Alerts contains either one or two buttons (Ok, Cancel etc). – Naveen Kumar R B Feb 15 '17 at 06:00

0 Answers0