zoukankan      html  css  js  c++  java
  • 我的常用自定义函数

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.common.exceptions import TimeoutException, NoSuchElementException
    from selenium.webdriver.common.action_chains import ActionChains
    driver=['1','2']
    def open_chrome():
        driver[0]=webdriver.Chrome()
        driver[0].get('http://www.baidu.com')
    def EC_located(one_group,value):
        '''
         目的:简化代码长度,参数1选择one或者group切换选中模式
        :param value:要找的值【CSS选择器】
        :return:选择到的对象
        '''
        wait = WebDriverWait(driver[0], 10)
        if one_group=="one":
            try:
                ecl=wait.until(EC.presence_of_element_located((By.CSS_SELECTOR,value)))
                return ecl
            except TimeoutException:
                print(value,'1元素未加载成功,等待超时')
        else:
            try:
                ecl=wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,value)))
                return ecl
            except TimeoutException:
                print(value,'1元素---组---未加载成功,等待超时')
  • 相关阅读:
    线性表之顺序表的结构与实现
    (转)面试题1:第一个只出现一次的字符
    c++ 虚基类应用
    c++ 多重继承
    c++ 单继承派生类的构造函数
    c++ 构造函数
    深入 Struts2 的配置
    c++ 结构体
    深入浅出C指针
    HTML5 小实例
  • 原文地址:https://www.cnblogs.com/zhangdingqu/p/9750331.html
Copyright © 2011-2022 走看看