from selenium import webdriver
import time
class cms(object):
a = webdriver.Chrome()
def init(self):
self.a.get("http://192.168.193.135:8080/cms/manage/login.do")
time.sleep(2)
self.a.find_element_by_name("userAccount").send_keys("admin")
time.sleep(2)
self.a.find_element_by_id("loginPwd").send_keys("123456")
time.sleep(2)
self.a.find_element_by_name("online").click()
time.sleep(2)
self.a.find_element_by_xpath('//[@id="loginBtn"]').click()
self.a.maximize_window()
time.sleep(2)
def exit(self):
self.a.find_element_by_link_text("退出").click()
def cx(self):
self.a.find_element_by_xpath('//[@id="menu-user"]/dt').click()
time.sleep(2)
self.a.find_element_by_link_text("用户管理").click()
b=self.a.find_element_by_xpath('//[@id="iframe_box"]/div[2]/iframe')
self.a.switch_to.frame(b)#进入iframe页
time.sleep(2)
self.a.find_element_by_id("searchValue").send_keys("222")
self.a.find_element_by_name("searchBtn").click()#点击
time.sleep(2)
self.a.find_element_by_xpath('/html/body/nav/a').click()#刷新
def create(self):
self.a.find_element_by_xpath('//[@id="menu-user"]/dt').click()
time.sleep(2)
self.a.find_element_by_link_text("用户管理").click()
b=self.a.find_element_by_xpath('//[@id="iframe_box"]/div[2]/iframe')
self.a.switch_to.frame(b)#进入iframe页
self.a.find_element_by_link_text("添加用户").click()
time.sleep(2)
c=self.a.find_element_by_xpath('//[@id="xubox_iframe1"]')
self.a.switch_to.frame(c)
time.sleep(2)
self.a.find_element_by_name("userName").send_keys("fss")
self.a.find_element_by_xpath('//[@id="userSex"]').click()
self.a.find_element_by_xpath('//[@id="userSex"]').click()
self.a.find_element_by_name("userMobile").send_keys("13154818951")
self.a.find_element_by_name("userEmail").send_keys("[email protected]")
self.a.find_element_by_name("userAccount").send_keys("fss")
self.a.find_element_by_name("loginPwd").send_keys("1315481895")
self.a.find_element_by_name("confirmPwd").send_keys("1315481895")
self.a.find_element_by_xpath('//[@id="submitBtn"]').click()
def qt(self):
self.a.find_element_by_xpath('//[@id="menu-user"]/dt').click()
time.sleep(2)
self.a.find_element_by_link_text("用户管理").click()
b=self.a.find_element_by_xpath('//[@id="iframe_box"]/div[2]/iframe')
self.a.switch_to.frame(b)#进入iframe页
time.sleep(2)
self.a.find_element_by_xpath('//[@id="sysUserTab"]/tr[1]/td[9]/a[1]').click()
time.sleep(2)
self.a.find_element_by_xpath('//*[@id="xubox_layer1"]/div[1]/span[2]/a[1]').click()
if name == 'main':
b=cms()
# b.login()
# b.exit()
b.qt()