I need to switch to an iframe that has a dynamic name and id.
<iframe name="easyXDM_1435765828615" id="easyXDM_1435765828615">...</iframe>
I noticed LeadFoot has a switchToFrame() function, but when I pass it an element that was returned from find() I get the error "MoveTargetOutOfBounds: POST http.../moveto / {"element":"16"} Offset within element cannot be scrolled into view".
Is there a better way to do this using execute() and some javascript, or how can I make switchToFrame() work?
Depending on how your iframes are setup on the page you could try something like this:
.switchToFrame(null)
.findAllByClassName('iframe')
.then(
function(iframes) {
new remote.constructor(remote.session)
.switchToFrame(iframes[iframes.length-1])
}
)
This assumes that the iframe you want to switch to is last to be found, which is obviously a big assumption. You might be able to tweak this though, if the dynamically created iframes appear in the same order every time.
来源:https://stackoverflow.com/questions/31167427/how-to-switch-iframes-internjs