如何使用Selenium WebDriver.io在框架集中切换子帧

如何使用Selenium WebDriver.io在框架集中切换子帧

问题描述:

我切换框架"main",切换框架"midFrame"正在工作. 但是开关框左"不起作用.请看一下上面的脚本吗?
谢谢,

I switch frame 'main', switch frame 'midFrame' is working. But switch frame 'left' is not working. Please, take a look at the above script?
Thanks,

使用lib: http://webdriver.io/api/protocol/frame.html

<html>
<head></head>
<frameset frameborder="0" border="0" framespacing="0" rows="80,*,20">
    <frameset frameborder="0" border="0" framespacing="0" cols="390,*">...</frameset>
    <frame name='main' src="/CorpWeb/IbsJsps/orbilogin.jsp">
        <html>
            <head></head>
            <frameset rows="18,22,*" cols="*" ...>
                <frame src'...' name='newMidframe'>...</frame>
                <frame src'...' name='midFrame'>...</frame>
                <frameset rows="245,*" cols="*">
                    <frame src='...' name='left'>...</frame>
                    <frame src='...' name='mainFrame'>...</frame>
                </frameset>
            </frameset>
        </html>
    </frame>
    <frame> ... </frame>    
</frameset>
</html>

错误:

{[RuntimeError:RuntimeError (NoSuchFrame:8)由于找不到该帧,因此无法满足切换到该帧的请求. 问题:没有这样的框架

{ [RuntimeError: RuntimeError (NoSuchFrame:8) A request to switch to a frame could not be satisfied because the frame could not be found. Problem: no such frame

 Callstack:
 -> frame("mainFrame") ]   message: 'RuntimeError\n     (NoSuchFrame:8) A request to switch to a frame could not be satisfied

因为找不到框架.\ n问题:没有这样的框架 frame \ u001b [1; 30m \ n \ n Callstack:\ n-> frame("mainFrame")\ n',
名称:"RuntimeError",hasCallStack:true} null {[RuntimeError: RuntimeError (NoSuchFrame:8)由于找不到该帧,因此无法满足切换到该帧的请求. 问题:没有这样的框架

because the frame could not be found.\n Problem: no such frame\u001b[1;30m\n\n Callstack:\n -> frame("mainFrame")\n',
name: 'RuntimeError', hasCallStack: true } null { [RuntimeError: RuntimeError (NoSuchFrame:8) A request to switch to a frame could not be satisfied because the frame could not be found. Problem: no such frame

 Callstack:
 -> frame("mainFrame") ]   message: 'RuntimeError\n     (NoSuchFrame:8) A request to switch to a frame could not be satisfied

因为找不到框架.\ n问题:没有这样的框架 frame \ u001b [1; 30m \ n \ n Callstack:\ n-> frame("mainFrame")\ n',
名称:"RuntimeError",hasCallStack:true}

because the frame could not be found.\n Problem: no such frame\u001b[1;30m\n\n Callstack:\n -> frame("mainFrame")\n',
name: 'RuntimeError', hasCallStack: true }

原因是

左/主框架 两者在 midFrame 下均不存在.

left/mainFrame both are not present under midFrame.

要切换到它们,请切换回defaultContentmain框架,然后切换到left/mainFrame.您可以在html标签中看到 midFrame元素在下一个框架集开始之前结束.

To switch to them please switch back to defaultContent or main frame, and then switch to left/mainFrame. You can see in the html tag, midFrame element ends before next frameset starts.