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.
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:
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:
the NoSuchFrameException is caught, and program execution continues.