I'v AJAX based application and have some frames on it and want to switch to it hence I've used frameToBeAvailableAndSwitchToIt()
method.
Suppose now I'm on default context of a page(i.e not in any of the frames) and want to switch to testFrame
using following code -
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(testFrame));
JavascriptExecutor jsExecutor = (JavascriptExecutor)driver;
String currentFrameName = (String) jsExecutor.executeScript("return self.name");
System.out.println("***************** Current frame using self.name " + currentFrameName);
This returns empty string as a value of currentFrameName
which indicates that we haven't switched to testFrame
, even though explicit wait call has succeeded.
This issue reproduces intermittently which causes tests to be flaky. Could you please suggest how to make this stable?
EDIT
I edited my question where earlier I had mentioned - I'm in frameA
and then want to switch to frameB
but that is not a case. I want to switch from default content of a page to a frame. Sorry for putting wrong information at first place.