Selenium IDE是否等效于driver.switchTo.defaultContent?

时间:2019-06-11 19:16:52

标签: iframe selenium-ide

使用新的Selenium IDE,我找不到从iframe切换回父页面默认内容的方法。 Selenium IDE脚本进入iframe后找不到按钮。

失败之前的步骤包括切换到iframe:index = 2并等待iframe中可见的元素。尝试在主要内容上查找按钮时,找不到元素。

尝试了以下方法以切换回默认内容:

  • Command ='选择框架'; Target =''
  • Command ='选择框架'; Target ='index = 0'
  • Command ='选择框架'; Target ='index = 1'
  • Command ='选择框架'; Target ='relative = parent'
  • Command ='选择框架'; Target ='relative = top'
  • Command ='选择窗口'; Target =”(如this answer中所述)
  • Command ='选择窗口'; Target ='relative = parent'
  • Command ='选择窗口'; Target ='relative = top'

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

至少在Katalon Selenium IDE和UI.Vision Selenium IDE中有效:

  • Command ='选择框架'; Target ='relative = top'

测试宏:(可以粘贴到Selenium IDE ++的source code tab中)

{
  "Name": "DemoFrames",
  "CreationDate": "2019-6-11",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://ui.vision/demo/webtest/frames/",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Reduce replay speed so we can better see what is going on...",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "medium",
      "Value": "!replayspeed"
    },
    {
      "Command": "selectFrame",
      "Target": "index=0",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "name=mytext1",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "name=mytext1",
      "Value": "Frame1 (index=0)"
    },
    {
      "Command": "selectFrame",
      "Target": "relative=top",  <==== HERE!!!
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "index=1",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "name=mytext2",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "name=mytext2",
      "Value": "Frame2 (index=1)"
    },
    {
      "Command": "selectFrame",
      "Target": "relative=top",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "index=2",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "name=mytext3",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "name=mytext3",
      "Value": "Frame3 (index=2)"
    },
    {
      "Command": "selectFrame",
      "Target": "relative=top",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "index=3",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "name=mytext4",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "name=mytext4",
      "Value": "Frame4 (index=3)"
    },
    {
      "Command": "selectFrame",
      "Target": "relative=top",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "index=4",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "name=mytext5",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "name=mytext5",
      "Value": "Frame5 (index=4)"
    },
    {
      "Command": "selectFrame",
      "Target": "relative=top",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "index=2",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "name=mytext3",
      "Value": "now testing iframe inside this frame"
    },
    {
      "Command": "selectFrame",
      "Target": "index=0",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "//span[contains(text(),\"UI.Vision IDE\")]",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "css=input.quantumWizTextinputSimpleinputInput.exportInput",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "css=input.quantumWizTextinputSimpleinputInput.exportInput",
      "Value": "iframe in frame: works!"
    },
    {
      "Command": "clickAndWait",
      "Target": "css=span.quantumWizButtonPaperbuttonLabel.exportLabel",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "name=entry.1572386418",
      "Value": "This is a single line test..."
    },
    {
      "Command": "clickAndWait",
      "Target": "//*[@id=\"mG61Hd\"]/div/div[2]/div[3]/div[1]/div[1]/div[2]/div[2]",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "relative=top",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "index=2",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "name=mytext3",
      "Value": "Test completed!"
    }
  ]
}
相关问题