0

I will appreciated your help to slove my popup windows problem

I try to do an Automate test with Selenium and Java . When I execute the test with FireFox 30, there is an popup windows that appears in the middle of my execution window . This popup windows covers the first window.

How can eliminate or disable this popupwindow ?

I tired a lot of thing , also this but still no working

String winHandleBefore = driver.getWindowHandle(); 
// Perform the click operation that opens new window

// Switch to new window opened

for (String winHandle : driver.getWindowHandles()) {
    driver.switchTo().window(winHandle);
}
// Perform the actions on new window

driver.close(); //this will close new opened window
//switch back to main window using this code

driver.switchTo().window(winHandleBefore);

This is my code

    **This is my code:**


      public void setUp() throws Exception{
      DesiredCapabilities capability = new DesiredCapabilities();
      capability.setCapability("browser", "Firefox");
      capability.setCapability("browser_version", "30.0");
      capability.setCapability("os", "Windows");
      capability.setCapability("os_version", "7");
      capability.setCapability("resolution", "1280x1024");
      capability.setCapability("build", "JUnit - Sample");
      capability.setCapability("browserstack.debug", "true");
      FirefoxProfile profile = new FirefoxProfile();
      profile.setPreference("plugin.state.flash", 0);
    capability.setCapability(FirefoxDriver.PROFILE, profile);
    driver = new RemoteWebDriver(new URL("http://a@hub.browserstack.com/wd/hub"),capability);
  baseUrl = "http://www.d.com/";
  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

}

    @Test
    public void testCodigo3() throws Exception {
    driver.get(baseUrl + "/");
    driver.manage().window().maximize();

    //Menu
    WebElement menu=driver.findElement(By.xpath("//div[@id='olMain']/nav/ul/li[4]/a/span"));

      //SubMenu
    WebElement submenu =driver.findElement(By.xpath("//div[@id='olMain']/nav/ul/li[4]/div/div/ol/li[3]/ul/li/a"));
    Actions action = new Actions (driver);
    action.moveToElement(menu).perform();
    Thread.sleep(2000);
    action.click(submenu);
    driver.findElement(By.linkText("TV LED")).click();
erakitin
  • 11,437
  • 5
  • 44
  • 49
Ms White
  • 1
  • 1
  • 1
  • Have you tried using the `Alert alert = driver.switchTo().alert(); alert.accept();` ? – Mark Rowlands Jul 09 '14 at 13:03
  • Thanks Erakitin, I tried with alert but didn't work. – Ms White Jul 10 '14 at 07:46
  • Thanks Erakitin, I tried with alert but it didn't work. This is the error message: No alert is present (WARNING: The server did not provide any stacktrace information) I am trying with this post http://stackoverflow.com/questions/16448173/selenium-automatically-accepting-alerts – Ms White Jul 10 '14 at 07:54
  • It sounds like its not an `alert`, could it be an iframe? Is the 'popup' html or not? – Mark Rowlands Jul 10 '14 at 08:09
  • Now you say that, I verifed and i think is an iframe, i try to do the test in my computer and the window display behind the principal window and with a different adress: http://vu.adschoom.com/clicki/9/529/1 – Ms White Jul 11 '14 at 08:36
  • If there is an `iframe` element, use `driver.switchTo().frame(x)` method. You'll need to supply either the integer that references that frame, or usually easier, supply the element using a `driver.findElement()` like normal. – Mark Rowlands Jul 11 '14 at 10:32

0 Answers0