码迷,mamicode.com
首页 > Web开发 > 详细

web端测试之封装公共部分

时间:2019-10-23 18:23:24      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:element   rom   find   com   implicit   drive   out   efault   imp   

from time import *  
from selenium import webdriver

def login(self,username,passwd):
self.dr=webdriver.Chrome()
self.dr.implicitly_wait(10)------隐式等待
self.dr.get(‘具体网址eg:http://baidu.com‘) -----
self.dr.find_element_by_xpath("//img[@src=‘themes/default/images/bnt_log.gif‘]").click()
self.dr.find_element_by_name(‘username‘).send_keys(username)
self.dr.find_element_by_name(‘password‘).send_keys(passwd)
self.dr.find_element_by_name(‘submit‘).click()
sleep(5)

def logout(self):
sleep(3)
self.dr.quit()----

web端测试之封装公共部分

标签:element   rom   find   com   implicit   drive   out   efault   imp   

原文地址:https://www.cnblogs.com/saran/p/11727650.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!