from selenium import webdriver
import time,os
from cwp.Page.PageLogin import PageLogin
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
class PageBoard():
def __init__(self, driver=None):
if driver is None:
os.system('taskkill /im chromedriver.exe /F')
self.driver = webdriver.Chrome()
else:
self.driver = driver
#定义元素
uesrleader_loc = (By.XPATH,'id("menu-cwp-pps")/li[2]/a[1]/span[1]/span[1]')
weixinuser_loc = (By.XPATH,'id("menu-userManagement")/li[1]/a[1]/span[1]/span[1]')
newadd_loc = (By.XPATH,'id("datagrid-toolbar")/a[1]/span[1]')
name_loc = (By.ID,'saveForm-name')
phonenum_loc = (By.ID,'saveForm-phoneNo')
huozhukuang_loc = (By.XPATH,'//*[@id="saveForm"]/div[4]/span[2]/span')
chosehuozhu_loc = (By.ID,'datagrid-row-r2-2-1')
savebtn_loc = (By.XPATH,'id("saveForm-button")/a[1]/span[1]')
def publish(self):
pagelogin = PageLogin(self.driver)
page_board = pagelogin.login('admin', '123', '1024')
self.driver.find_element(*self.uesrleader_loc).click()
time.sleep(1)
self.driver.find_element(*self.weixinuser_loc).click()
time.sleep(1)
self.driver.switch_to_frame('frame_outsideUserManage')
self.driver.find_element(*self.newadd_loc).click()
time.sleep(1)
self.driver.find_element(*self.name_loc).send_keys("测试")
time.sleep(1)
self.driver.find_element(*self.phonenum_loc).send_keys("13888888886")
time.sleep(1)
self.driver.find_element(*self.huozhukuang_loc).click()
self.driver.find_element(*self.chosehuozhu_loc).click()
self.driver.find_element(*self.huozhukuang_loc).click()
time.sleep(1)
self.driver.find_element(*self.savebtn_loc).click()
"""
self.driver.find_element_by_xpath('id("menu-cwp-pps")/li[2]/a[1]/span[1]/span[1]').click()
time.sleep(1)
self.driver.find_element_by_xpath('id("menu-userManagement")/li[1]/a[1]/span[1]/span[1]').click()
time.sleep(1)
self.driver.switch_to_frame('frame_outsideUserManage')
self.driver.find_element_by_xpath('id("datagrid-toolbar")/a[1]/span[1]').click()
time.sleep(1)
self.driver.find_element_by_id('saveForm-name').send_keys("测试")
time.sleep(1)
self.driver.find_element_by_id('saveForm-phoneNo').send_keys("13888888886")
time.sleep(1)
self.driver.find_element_by_xpath('//*[@id="saveForm"]/div[4]/span[2]/span').click()
self.driver.find_element_by_id('datagrid-row-r2-2-1').click()
self.driver.find_element_by_xpath('//*[@id="saveForm"]/div[4]/span[2]/span/a').click()
time.sleep(1)
self.driver.find_element_by_xpath('id("saveForm-button")/a[1]/span[1]').click()
"""
if __name__=="__main__":
pageboard1 = PageBoard()
pageboard1.publish()