How to switch iframes InternJS

我怕爱的太早我们不能终老 提交于 2019-12-08 08:33:15

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!