zoukankan      html  css  js  c++  java
  • Helium文档13-WebUI自动化-helium快速切换到selenium状态并调用其方法

    前言

    前面说过helium是对Selenium 进行了封装,那么我们如何使用selenium的方法呢,通过下面的介绍,我们能够清楚在helium中能够使用selenium的任何方法

    入参介绍

    def get_driver():
    """
    Returns the Selenium WebDriver currently used by Helium to execute all
    commands. Each Helium command such as ``click("Login")`` is translated to a
    sequence of Selenium commands that are issued to this driver.
    """
    return _get_api_impl().get_driver_impl()

    使用说明

    我们参考一篇博文

    Selenium2+python自动化28-table定位

    https://www.cnblogs.com/yoyoketang/p/6287962.html

    其中定位代码如下:

    五、参考代码:

    # coding:utf-8
    from selenium import webdriver
    import time
    url = 'file:///C:/Users/Gloria/Desktop/table.html'
    driver = webdriver.Firefox()
    driver.get(url)
    time.sleep(3)
    t = driver.find_element_by_xpath(".//*[@id='myTable']/tbody/tr[2]/td[1]")
    
    print(t.text)

    我们用helium怎么来快速切换到selenium呢?

    代码如下:

    from helium import *
    url = 'file:///C:/Users/Gloria/Desktop/table.html'
    start_chrome(url)
    driver = get_driver()  #这里就是切换了
    t = driver.find_element_by_xpath(".//*@id='myTable']/tbody/tr[2]/td[1]")
    print(t.text)

     使用了selenium 后我们怎么再使用helium呢

    只要继续使用helium就可以,不用其他操作

    欢迎交流

    310678696

  • 相关阅读:
    NIS详解
    Linux的硬链接和软链接有何区别?
    使用sed和cut将进程的pid过滤出来
    sticky(粘附位)的含义
    使用ulimit来产生core dump文件
    Linux常用shell脚本
    LFS5.0安装完成心得
    sshd + xinetd 限制IP登录
    Linux磁盘限额配置(Ext3)
    LFS安装手记
  • 原文地址:https://www.cnblogs.com/weitung/p/13616940.html
Copyright © 2011-2022 走看看