coding:utf-8
引用webdriver
from selenium import webdriver
用来查找页面元素的类
from selenium.webdriver.common.by import By
睡眠时间
import time
path = r’D:\webdriver\chromedriver.exe’
打开浏览器
wd = webdriver.Chrome(executable_path=path)
wd.set_page_load_timeout(5)
#如果页面3秒钟都还没有加载完成的话
#那么我们继续尝试去做其它控件的操作
try:
wd.get(‘http://192.168.1.251:9012/ui/test/ex14’)
except Exception as e:
print(e)
finally:
#不可点击按钮的属性
noClc = wd.find_element(By.ID,‘notclick’)
# 不可点击按钮的属性
noSee = wd.find_element(By.NAME, ‘start’)
#获取标签的名称
print(noClc.tag_name)
#获取标签的尺寸
print(noClc.size)
#获取标签的文本
print(noClc.text) #****
print('----------------------------------')
#获取是否可以点击
print(noClc.is_enabled())
#获取控件当前是否可见
print(noSee.is_displayed())
print('----------------------------------')
#获取指定属性的值
print(noClc.get_attribute('class')) #****
print(noClc.get_attribute('lay-submit'))