自动化框架——PO设计模式自学——第三种定位方法

import time
from selenium import webdriver

driver = webdriver.Firefox()
driver.get('http://www.baidu.com')

time.sleep(5)

driver.find_element('id','kw').send_keys('中国')

driver.find_element('id','su').click()

time.sleep(10)


driver.quit()

 

使用find_element()定位方法(字符串中间是空格需注意)

by_id= "id"
by_xpath = "xpath"
by_link_text = "link text"
by_partial_text = "partial link text"
by_name = "name"
by_tag_name = "tag name"
by_class_name = "class name"
by_css_selector = "css selector"

 

 

 

location = 'id'
argument = 'password2'
br.find_element(location, argument)       # 等同于 br.find_element_by_id('password2')

 

 

 

posted @ 2020-03-31 20:02  小白龙白龙马  阅读(420)  评论(0编辑  收藏  举报