TA的每日心情 | 开心 昨天 06:25 |
---|
签到天数: 2028 天 连续签到: 4 天 [LV.Master]测试大本营
|
- # coding:utf-8
- from selenium import webdriver
- from time import sleep
- class RanzhiCommon(object):
- def __init__(self, driver, base_url):
- driver = webdriver.Chrome()
- self.old_driver = driver
- self.base_url = base_url
- def open_page(self, driver):
- driver = self.old_driver
- driver.get(self.base_url)
- sleep(3)
- def log_in(self, account, password):
- driver = self.old_driver
- #用户名
- element_account = driver.find_element_by_name('username')
- element_account.clear()
- element_account.send_keys(account)
- sleep(2)
- #密码
- element_password = driver.find_element_by_id('password')
- element_password.click()
- element_password.send_keys(password)
- driver.find_element_by_xpath('//*[@id="loginForm"]/table/tbody/tr[1]/td[2]/table/tbody/tr/td[2]/table/tbody/tr[13]/td/table/tbody/tr/td[2]/a/b').click()
- def log_out(self):
- driver = self.old_driver
- driver.find_element_by_xpath('//*[@id="menu-shiva_trtms_ground"]/li[1]/a/span').click()
- driver.find_element_by_xpath('//*[@id="menu-frame-system-tools"]/li[5]/a/span/span[1]/span').click()
- 这是第二个类
复制代码 |
|