# -*- coding:utf-8 -*-
# 2020/5/21
# Administrator
from seleniumimport webdriver
from selenium.webdriver.common.byimport By
import time
driver = webdriver.Chrome()
driver.get(r'D:\AutomationTest\WebUI_Selenium\Day1\test.html')
#1.ID定位元素
text = driver.find_element_by_id('abc').text
#2. name定位元素
driver.find_element_by_name('a1').send_keys('搜索')
#driver.find_element(By.NAME,"a1").send_keys('aaa')
#3.Xpath定位语速
option= driver.find_element_by_xpath('/html/body/div/select/option[3]')
option.click()
print(option.text)
#4. 链接文本定位元素
baidu1=driver.find_element_by_link_text('访问百度')
#5. 通过部分链接文本定位元素
baidu=driver.find_element_by_partial_link_text('百度')
baidu.click()
#6.通过tagname定位元素
tagele=driver.find_element_by_tag_name('option').text
print(tagele)
#7.通过class name定位元素
a2 = driver.find_element_by_class_name('a2')
# 通过css选择器
print(a2.text)
time.sleep(2)
driver.quit()