zoukankan      html  css  js  c++  java
  • Selenium多层级的iframe中元素的定位

    很多时候我们遇到多层级的iframe就会想各种方法去获取iframe中的元素,但其实很简单就可以做到的,就是一级一级获取就可以了,获取至你需要的那个层级即可,下面看下实际的案例;(转)

    <frame src="" id="index_main" name="main" scrolling="Yes" noresize="noresize">
            <iframe id="Editor1" src="" frameborder="0" scrolling="no" >
                  <iframe id="eWebEditor" width="100%" height="100%" scrolling="yes" frameborder="0" src="">
                      <input type="text" id="TeacherTxt" name="Teacher" size="12" maxlength="12" >
                </iframe>
            </iframe>
    </iframe>
     
    示例:
             @Test  
        public void phoneLogin() throws Exception{  

                    WebDriver chrome = new ChromeDriver();
             chrome.switchTo().frame("index_main");
           chrome.switchTo().frame("Editor1");
           chrome.switchTo().frame("eWebEditor");
           chrome.findElement(By.id(" TeacherTxt")).sendKeys("测试Iframe");

           chrome.switchTo().defaultContent();  
                }
     
    注意:最后只需要退出一次iframe即可;
  • 相关阅读:
    oracle导入dmp数据库文件
    Merge into的使用详解-你Merge了没有【转】
    远程调试
    安卓Activity、service是否处于同一进程
    AIDL机制实现进程间的通讯实例
    安卓android:scaleType属性
    oracle索引
    Json-lib用法
    浅谈position: absolute和position:relative
    Tab Layout教程
  • 原文地址:https://www.cnblogs.com/weiwei-python/p/9808004.html
Copyright © 2011-2022 走看看