#-*-coding:utf-8-*- from selenium import webdriver from time import sleep driver = webdriver.Firefox() url = "https://www.baidu.com/" # url = "http://www.cnblogs.com/tDayUp/" driver.get(url) print (driver.title) #页面刷新 # print (driver.refresh()) #打印浏览器的名称 print (driver.name) # #获取元素属性值 这里可以用来做页面校验定位 # qu = driver.find_element_by_css_selector("#su").get_attribute("value") # # print type(qu) # print qu #判断隐形与否 这里是bool值返回判断 yxyf = driver.find_element_by_css_selector("#su").is_displayed() print yxyf #是否激活,这个有啥用我也不知道,估计是看某个元素是不是可用吧! yxyf1 = driver.find_element_by_css_selector("#su").is_enabled() print yxyf1 #打印元素大小, 返回时字典,直接输出字典值 ysSize = driver.find_element_by_css_selector("#su").size print ysSize print ysSize["width"] sleep(3) driver.quit()