import time
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('URL')
driver.maximize_window()
driver.implicitly_wait(10)
# # send_keys():在对象上模拟按键输入
# driver.find_element_by_name('username').send_keys('admin')
# time.sleep(2)
# # clear()清除文本内容
# driver.find_element_by_name('username').clear()
# time.sleep(1)
# driver.find_element_by_name('username').send_keys('test01')
# driver.find_element_by_name('password').send_keys('123456')
# time.sleep(2)
# driver.find_element_by_id('J_sidebar_login').click()
# size : 返回对象的尺寸
el = driver.find_element_by_name('username')
print(el.size)
# text : 获取对象的文本
time.sleep(1)
print(driver.find_element_by_class_name('sendpwd').text)
# get_attribute(“属性名”):获取对象的属性值
id = el.get_attribute('id')
cla = el.get_attribute('class')
name = el.get_attribute('name')
print(id,cla,name)
# is_displayed():用来判断对象是否可见,即css的display属性是否为none
print('对象是否可见',el.is_displayed())
# is_enabled():判断对象是否被禁用
print('判断对象是否被禁用:',el.is_enabled())
# is_selected():判断对象是否被选中
driver.find_element_by_id('head_checkbox').click()
time.sleep(1)
print('判断对象是否被选中:',driver.find_element_by_id('head_checkbox').is_selected())
# tag_name:获取对象标签名称
print('获取对象标签名称:',el.tag_name)
# location:获取元素坐标
print('获取元素坐标:',el.location)