问题
The following command runs successfully with Firefox Driver but with PhantomJS I am facing an error message:
driver.switch_to.frame(frame)
Error Message with PhantomJS:
errorMessage":"Unable to switch to frame"
Has anyone faced the issue previously and can help me here?
回答1:
PhantomJS/GhostDriver has this issue which has been resolved - https://github.com/detro/ghostdriver/issues/194
Below statements work with GhostDriver. There is no difference in the statements that have to be used with Ghostdriver.
driver.switchTo().frame(frame_index)
driver.switchTo().frame(frame_id)
driver.switchTo().frame(frame_object)
Put a wait until the iframe is located
wait.until(ExpectedConditions.presenceOfElementLocated("identifier of the frame"))
Make sure that the iframe is displayed in the page source.
来源:https://stackoverflow.com/questions/29385450/not-able-to-switch-frame-in-phantomjs-but-switches-successfully-with-firefox-usi