zoukankan      html  css  js  c++  java
  • 隐式等待的两种写法

    #-*- coding:utf-8 -*-
    
    from selenium import webdriver
    from selenium.webdriver.support.wait import WebDriverWait
    
    #隐式等待方法1
    def credit1(username):
        driver = webdriver.Chrome()
        driver.get("http://credit.risk.jc.learn.com/loan-credit/user/caslogin")
        driver.maximize_window()
        WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id("username")).send_keys(username)
        WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id("pwd")).send_keys("Cs654321")
        WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_class_name("btn")).click()
    
    
    
    
    
    
    
    
    
    from selenium import webdriver
    from selenium.webdriver.support.wait import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC  # 设置等待执行语句
    
    
    #隐式等待方法2
    def credit2(username):
        driver = webdriver.Chrome()
        driver.get("http://credit.risk.jc.learn.com/loan-credit/user/caslogin")
        driver.maximize_window()
        WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'username'))).send_keys(username)
        WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'pwd'))).send_keys("Cs654321")
        WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'btn'))).click()
    
    
    
    # credit1("11041433")
    credit2("11041433")


    一切技术都是为业务服务,脱离业务的技术一文不值!

  • 相关阅读:
    简单工厂笔记
    P3369 【模板】普通平衡树 Treap树堆学习笔记
    tp5阿里云短信验证码
    centos 安装php
    tp6.0.2开启多应用模式
    linux navicat最新版过期
    git commit之后 取消commit
    服务器重置之后ssh root@报错
    git pull push 每次都需要输入账号和密码
    跨域问题 php
  • 原文地址:https://www.cnblogs.com/bubutianshu/p/11266741.html
Copyright © 2011-2022 走看看