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   

  • 相关阅读:
    TP隐藏入口
    CentOs5.2中PHP的升级
    centos 关闭不使用的服务
    也不知怎么了LVS.SH找不到,网上搜了一篇环境搭配CENTOS下面的高可用 参考
    三台CentOS 5 Linux LVS 的DR 模式http负载均衡安装步骤
    分享Centos作为WEB服务器的防火墙规则
    Openssl生成根证书、服务器证书并签核证书
    生成apache证书(https应用)
    openssl生成https证书 (转)
    ls -l 列表信息详解
  • 原文地址:https://www.cnblogs.com/lingxia/p/9504665.html
Copyright © 2011-2022 走看看