python测试selenium等待时间,并输出log,设置log级别

复制代码
__author__ = 'Jeff.xie'

import logging

from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from time import sleep

# selenium 等待的3种方式

# timd.sleep(固定等待)
# implicitly_wait(隐式等待)
# WebDriverWait(显示等待)

# level=logging.INFO LEVEL 设置为DEBUG,所有详细的log都会输出,建议设置成INFO,第三方包的log不会输出
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

# 记录不同级别的日志
logging.debug('这是一个debug消息')
logging.info('这是一个info消息')
logging.warning('这是一个warning消息')
logging.error('这是一个error消息')
logging.critical('这是一个critical消息')

driver = webdriver.Chrome()
driver.get("https://www.baidu.com")

driver.implicitly_wait(10)
logging.info('debug start')
driver.find_element(By.ID,"kw").send_keys("Java")
WebDriverWait(driver,15,1).until(EC.presence_of_element_located((By.ID,"su"))).click()

sleep(0.1)

logging.info('debug finish')
driver.close()
相关推荐
陈辛chenxin5 分钟前
【接口测试】Postman教程
python·selenium·测试工具·postman·可用性测试
乘乘凉10 分钟前
C#中的值传递和引用传递
java·开发语言·c#
程序员小远11 分钟前
Postman详解
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman
ThreeYear_s14 分钟前
【FPGA+DSP系列】——MATLAB simulink单相PWM全控整流电路基础版
开发语言·matlab·fpga开发
kaikaile199519 分钟前
基于高斯白噪声与瑞利衰落共同作用的OFDM系统仿真
开发语言·matlab
zwm_yy27 分钟前
php常用函数
开发语言·php·restful
钮钴禄·爱因斯晨37 分钟前
Python常见的文件操作
android·数据库·python
AI小云1 小时前
【数据操作与可视化】Pandas数据处理-Series数据结构
开发语言·数据结构·python·numpy·pandas
froginwe111 小时前
正则表达式 - 示例
开发语言
Python大数据分析@1 小时前
如何理解Python中的yield用法?
python