2

I'm working on a test case in Java and am using selenium to record a set of events and "replay" them to an app. The code is:

// *The app opens a new window*
// Get handle of the main window
        String mainWindowHnd = webDriver.getWindowHandle();
        // Get all open window handlers
        Set openWindows = webDriver.getWindowHandles();

    Iterator ite=openWindows.iterator();
    // Select the new windows (there are two that are open)
    while(ite.hasNext())
    {
        String popupHandle=ite.next().toString();
        if(!popupHandle.contains(mainWindowHnd))
        {
            webDriver.switchTo().window(popupHandle);
        }
    }

    WebElement liveId = webDriver.findElement(By.id("c_clogoc"));

The id of the last statement is valid but inaccessible due to a css banner that is shown when the new window is opened. Running selenium IDE gives the following events:

Command :: Target

click css=a.close

How can I replay the command in Java so that the web driver closes the banner?

1 Answer 1

2

Use the findElement by a CSS selector:

driver.findElement(By.cssSelector("a.close")).click();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.