• 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

  • 相关阅读:
    Redis分布式限流器
    [转] 详解Spring boot启动原理
    [转] 总结了N个真实线上故障
    加一(66)
    原地删除(27)
    旋转数组(189)
    买卖股票的最佳时机 II(122)
    最长公共前缀(14)
    两个数组的交集II(350)
    Django时区及naive datetime object和aware datetime object的区别
  • 原文地址:https://www.cnblogs.com/weitung/p/13616940.html
Copyright © 2020-2023  润新知