In years it is the first time I saw something like this, when I do a:


The result is always 1, but in fact, there is a main window opened and after a click, a popup opens.

My code may not help, because it is a javascript (server side) doing something I do not know on a 'onchange' event. I am trying to debug in Developer Tools, but it is being a tought activity. Here is the code anyway:

try {
        webActions.getFrameAndSwitchView(VidaNovaConstants.XPATH_FRAME_CRITICAS, config.getWebDriver());
        List<WebElement> lstSelects = config.getWebDriver().findElements(By.xpath(VidaNovaConstants.XPATH_SELECT_LIBERACAO_CRITICAS));
        for (WebElement elem : lstSelects) {
            webActions.selectCombo(elem, "Sim");
            if(config.getWebDriver().getWindowHandles().size() > 1) {
                if(webActions.exists("//span[contains(text(),'Dados da Crítica']", "Não foi aberta a janela para motivo da liberação.")) {
                    selectMotivoPopup("Liberação Técnica");
                    setJustificativa("Liberando devido necessidade operacional.");
    } catch (Exception e) {
        logger.error("Erro ao liberar todas criticas na tela 9. " + e.getMessage());
        config.getReport().addStep("Erro ao liberar todas criticas na tela 9.");
        Assert.fail("Erro ao liberar todas criticas na tela 9.");

Never goes inside my condition (if).

The question is, how can I recognize this popup, to switch to it and interact with its elements?

I have set IE capatilites like this, including JAVASCRIPT_ENABLED and HANLES_ALERTS as false:

private WebDriver createIE() {
            Paths.get("").toAbsolutePath().toString() + "\\src\\main\\resources\\drivers\\IEDriverServer.exe"); 
    DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
    ieCapabilities.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, BLANK_PAGE);
    ieCapabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, true);
    ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    ieCapabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
    ieCapabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
    ieCapabilities.setCapability(JAVASCRIPT_ENABLED, false);
    ieCapabilities.setCapability(HANLES_ALERTS, false);
    ieCapabilities.setCapability(REQUIREDWINDOWSFOCUS, true);
    InternetExplorerOptions opt = new InternetExplorerOptions(ieCapabilities);
    webDriver = new InternetExplorerDriver(opt);
    return webDriver;

Any suggestions would help a lot on how to handle this situation.

  • What kind of "pop-up" is it? An alert? A modal? A new browser window?
    – Lee Jensen
    Sep 3 '19 at 22:07
  • It is a new browser window, but 'modified' due to javascripts doing sth's... There is no field to input addresss as an example. Sep 4 '19 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.