zoukankan      html  css  js  c++  java
  • Selenium-Switch与SelectApi接口详解

    switch

    我们在UI自动化测试时会出现新建一个tab弹出一个浏览器级别的弹框或者一个iframe,selenium为我们提供switch_to模块

    导入:

    # 第一种方式可以通过直接导入SwitchTo模块来进行操作

    from selenium.webdriver.remote.switch_to import SwitchTo
     
    # 第二种方式是直接通过Webdriver的switch_to来操作
    driver.switch_to
    其实webdriver在以前的版本中已经为我们封装好了切换Windows、Alert、Iframe,现在依然可以使用,但是会被打上横线,代表他已经过时了,建议使用SwitchTo类来进行操作。
     
    SwitchToWindows
     
    之前在webdriver api中已经介绍是切换浏览器句柄的,很有用

    handle = driver.current_window_handle返回当前浏览器句柄
    handles = driver.window_handles所有句柄
    eg:
    def open_new_window(self, css):
    '''
    Open the new window and switch the handle to the newly opened window.

    Usage:
    driver.open_new_window()
    '''
    original_windows = self.driver.current_window_handle
    el = self.get_element(css)
    el.click()
    all_handles = self.driver.window_handles
    for handle in all_handles:
    if handle != original_windows:
    self.driver.switch_to.window(handle)
     

    SwitchToFrame   

  • 相关阅读:
    java版扫雷
    隔离级别
    Servlet Analysis
    Session&Cookie
    centos上部署应用到tomcat
    在CentOS 7中安装与配置Tomcat-8.5方法
    centos7中安装、配置jdk(转载)
    java RE Validation常用
    hello2 source Analysis
    serlvet中的过滤器filter
  • 原文地址:https://www.cnblogs.com/lingxia/p/9504665.html
Copyright © 2011-2022 走看看