I'm trying to wait for Selenium to switch changing frames before waiting on another element. I.e.
var wait = new WebDriverWait(driver, 15);
wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Id("frameA"));
var wait2 = new WebDriverWait(driver, 15);
// wait for element within frameA to exist
wait2.Until(ExpectedConditions.ElementExists(By.Id("elementA")));
If I toss in a simple Thread.Sleep(1000);
before the second wait it functions fine, but without that I get the following error:
'unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot find context with specified id"}
enter code here
Is there a better way to wait for the frame context to switch finishing before waiting for an element within that frame to be populated?