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()
相关推荐
OTWOL几秒前
Python的顺序结构和循环结构
开发语言·python
大数据学习爱好者7 分钟前
基于python商品比价系统requests爬虫+可视化+Django框架
大数据·开发语言·python
代码的乐趣19 分钟前
支持selenium的chrome driver更新到133.0.6943.53
chrome·python·selenium
不会敲代码的XW31 分钟前
对比 LVS 负载均衡群集的 NAT 模式和 DR 模式,其各自的优势
开发语言·php
子午1 小时前
基于Python深度学习的【蘑菇识别】系统~卷积神经网络+TensorFlow+图像识别+人工智能
人工智能·python·深度学习
关关钧1 小时前
【R语言】t检验
开发语言·r语言
真想骂*1 小时前
Python中是否有类似R语言中rds的功能,可将对象保存为文件?
开发语言·python·r语言
zjkzjk77111 小时前
函数指针(Function Pointer)与 typedef int (*FuncPtr)(int, int);typedef与using(更推荐)
开发语言·c++·算法
一匹电信狗1 小时前
C++引用深度详解
c语言·开发语言·c++·visual studio
祝星阑1 小时前
Elixir语言的数据库交互
开发语言·后端·golang