Selenium 入门到精通系列
PS:Driver_Element 常用方法
例子
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2019-04-23 16:12:33
# @Author : BenLam
# @Link : https://www.cnblogs.com/BenLam/
from selenium import webdriver
driver=webdriver.Firefox()
driver.get("http://www.baidu.com/")
size=driver.find_element_by_id("kw").size
print(size)
#打印尺寸
text=driver.find_element_by_id("cp").text
print(text)
#返回属性值
attribute=driver.find_element_by_id("kw").get_attribute('type')
print(attribute)
#判断元素是否存在,返回结果为True或False
displayed=driver.find_element_by_id("kw").is_displayed()
print(displayed)
#判断元素是否选中,返回结果为True或False
selected=driver.find_element_by_xpath("//p[@id='TANGRAM__PSP_10__memberPassWrapper']/input").is_selected()
print(selected)
driver.quit()