Skip to content

Method switchTo(frame()) should wait until frame appears #212

@asolntsev

Description

@asolntsev

Travis travis.fricke@gmail.com, 7.08.2015:

I'm running into the same problem in some situations. For example, when switching frames, I first tried this:

try {
   switchTo().frame($(By.xpath("//frame[@name='theFrame']")));
}
catch (NoSuchFrameException ex) {
   System.out.println("Frame doesn't exist.  Continuing anyways.");
}

This is at a point in the test where theFrame might not exist on the page yet. The test is checking to see if the element exists, but first it has to switch to the right frame. When the frame doesn't exist, an error like the one from santoshsarma jayanthi is displayed, and java exits completely. It never reaches the catch block.

However, if instead I use this:

try {
   switchTo().frame("theFrame");
}
catch (NoSuchFrameException ex) {
   System.out.println("Frame doesn't exist.  Continuing anyways.");
}

the NoSuchFrameException is caught, and program execution continues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions