TA的每日心情 | 无聊 昨天 09:47 |
---|
签到天数: 528 天 连续签到: 1 天 [LV.9]测试副司令
|
1测试积点
那个不应该有多标签切换操作,但无论用什么定位都无法定位,有大神解释一下吗
- from commonlib.Commonlib import Common
- import time
- class baidu_login(Common):
- def login(self,user,pwd):
- self.open_url("https://www.baidu.com/")
- #点击登录按钮
- self.click("link","登录")
- time.sleep(2)
- #点击用户名登录按钮(百度上有两个登陆方式,一个是扫码的,一个是用户名登录)
- self.click("css","#TANGRAM__PSP_10__footerULoginBtn")
- self.input_data("id","TANGRAM__PSP_10__userName",user)
- self.input_data("id","TANGRAM__PSP_10__password",pwd)
- self.click("id","TANGRAM__PSP_10__submit")
复制代码 以下是调用的函数
- def LocateElement(self,locate_type,value):
- el=None
- if locate_type=="id":
- el=self.driver.find_element_by_id(value)
- elif locate_type=="name":
- el=self.driver.find_element_by_name(value)
- elif locate_type=="class":
- el=self.driver.find_element_by_class_name(value)
- elif locate_type=="link":
- el=self.driver.find_element_by_link_text(value)
- elif locate_type=="tag":
- el=self.driver.find_element_by_tag_name(value)
- elif locate_type=="xpath":
- el=self.driver.find_element_by_xpath(value)
- elif locate_type=="partial":
- el=self.driver.find_element_by_partial_link_text(value)
- elif locate_type=="css":
- el=self.driver.find_element_by_css_selector(value)
- if locate_type is not None:
- return el
复制代码
|
|