def add(driver, poolName, networkName, poolType2, vmNames): page.get_into_powerview(driver, '资源管理', '桌面池管理') driver.find_element_by_xpath( "//a[@id='dialog-link-desktop-pool-add']").click() driver.find_element_by_id("desktoppoolName").clear() driver.find_element_by_id("desktoppoolName").send_keys(poolName) Select(driver.find_element_by_id("netWorkId")).select_by_visible_text( networkName) driver.find_element_by_xpath( "//*[@id='createDesktopPoolForm']//label[text()='" + poolType2.value + "']/preceding-sibling::input[1]").click() for vmName in vmNames: driver.find_element_by_name("addVmBtnJS").click() driver.find_element_by_name("vmName").clear() driver.find_element_by_name("vmName").send_keys(vmName) driver.find_element_by_xpath( "//*[@id='noDesktop']//button[contains(text(),'查询')]").click() time.sleep(1) driver.find_element_by_xpath( "//span[contains(text(),'添加虚拟机')]/../..//span[@title='" + vmName + "']/ancestor::tr[1]//input").click() driver.find_element_by_xpath( "//span[contains(text(),'添加虚拟机')]/../..//button[text()='确定']" ).click() driver.find_element_by_xpath( "//span[contains(text(),'创建桌面池')]/../..//button[text()='确定']" ).click() #self.assertTrue(self.is_element_present(By.XPATH, "//span[@id='infoMessage' and contains(text(),'成功')]")) driver.find_element_by_xpath( "//span[@id='infoMessage']/../../..//button[text()='确定']").click()
def delete(driver, poolName): page.get_into_powerview(driver, '资源管理', '桌面池管理') pool.__search_pool(driver, poolName) driver.find_element_by_xpath( "//table[@id='stretch-table']//a[text()='" + poolName + "']/ancestor::tr[1]//a[text()='删除']").click() driver.find_element_by_xpath(constant.OKBUTTONPATH).click()
def delete(driver, deliveryname): page.get_into_powerview(driver, '资源管理', '桌面交付组') delivery.__search_delivery(driver, deliveryname) driver.find_element_by_xpath( u"//*[@id='content']//a[contains(text(),'" + deliveryname + "')]/../..//a[text()='删除']").click() driver.find_element_by_xpath(constant.OKBUTTONPATH).click()
def dealocatevm(driver, deliveryname, userName): page.get_into_powerview(driver, '资源管理', '桌面交付组') delivery.__get_into_delivery_userlist_page(driver, deliveryname) driver.find_element_by_xpath("//*[@id='userList']//td[text()='" + userName + "']/ancestor::tr[1]//input").click() driver.find_element_by_link_text("解除分配").click() driver.find_element_by_xpath(constant.OKBUTTONPATH).click()
def removevm(driver, poolName, vmName): page.get_into_powerview(driver, '资源管理', '桌面池管理') pool.__search_pool(driver, poolName) driver.find_element_by_link_text(poolName).click() time.sleep(1) driver.find_element_by_link_text("虚拟机").click() driver.find_element_by_xpath("//table[@id='vmList']//td[text()='" + vmName + "']/ancestor::tr[1]//input").click() driver.find_element_by_name("delVmBtn").click() driver.find_element_by_xpath(constant.OKBUTTONPATH).click()
def randomalocatevmtouser(driver, deliveryname, userNames): page.get_into_powerview(driver, '资源管理', '桌面交付组') delivery.__get_into_delivery_userlist_page(driver, deliveryname) Select(driver.find_element_by_xpath( "(//select[@id='pageSize'])[3]")).select_by_visible_text("100") for userName in userNames: driver.find_element_by_xpath("//*[@id='userList']//td[text()='" + userName + "']/ancestor::tr[1]//input").click() time.sleep(1) driver.find_element_by_link_text("随机分配").click() driver.find_element_by_xpath(constant.OKBUTTONPATH).click()
def addvm(driver, poolName, vmName): page.get_into_powerview(driver, '资源管理', '桌面池管理') pool.__search_pool(driver, poolName) driver.find_element_by_link_text(poolName).click() time.sleep(1) driver.find_element_by_link_text("虚拟机").click() driver.find_element_by_name("addVmBtnJava").click() driver.find_element_by_name("vmName").clear() driver.find_element_by_name("vmName").send_keys(vmName) driver.find_element_by_xpath(constant.QUERYBUTTONPATH).click() driver.find_element_by_xpath( "//span[contains(text(),'添加虚拟机')]/../..//span[@title='" + vmName + "']/ancestor::tr[1]//input").click() driver.find_element_by_xpath(constant.OKBUTTONPATH).click()
def removeusers(driver, deliveryname, userNames): page.get_into_powerview(driver, '资源管理', '桌面交付组') delivery.__search_delivery(driver, deliveryname) driver.find_element_by_link_text(deliveryname).click() driver.find_element_by_id("delivery_user_index").click() time.sleep(1) Select(driver.find_element_by_xpath( "(//select[@id='pageSize'])[2]")).select_by_visible_text("100") time.sleep(1) for userName in userNames: driver.find_element_by_xpath("//*[@id='userList']//td[text()='" + userName + "']/ancestor::tr[1]//input").click() driver.find_element_by_link_text("移除用户").click() driver.find_element_by_xpath(constant.OKBUTTONPATH).click()
def addusers(driver, deliveryname, userNames): page.get_into_powerview(driver, '资源管理', '桌面交付组') delivery.__search_delivery(driver, deliveryname) driver.find_element_by_link_text(deliveryname).click() driver.find_element_by_id("delivery_user_index").click() time.sleep(1) for userName in userNames: driver.find_element_by_link_text(u"添加用户").click() driver.find_element_by_id("userName").clear() driver.find_element_by_id("userName").send_keys(userName) driver.find_element_by_xpath( u"//*[@id='popCurrent']//input[@value='查询']").click() time.sleep(1) driver.find_element_by_xpath( "//*[@id='user_table_info']//td[text()='" + userName + "']/ancestor::tr[1]//input").click() driver.find_element_by_xpath(constant.OKBUTTONPATH).click()
def createVMbyISO(driver, vmName, offeringName, isoName, networkName, assginIP): page.get_into_powerview(driver, '资源管理', '创建虚拟机') creatvm = driver.find_element_by_xpath( ".//*[@id='content']/div[2]/div[2]") ActionChains(driver).move_to_element(creatvm).move_by_offset( 10, 10).perform() driver.find_element_by_xpath(".//*[@id='createIso']").click() time.sleep(1) driver.find_element_by_id("vmName").clear() driver.find_element_by_id("vmName").send_keys(vmName) Select(driver.find_element_by_id("offeringId")).select_by_visible_text( offeringName) Select(driver.find_element_by_id("templateId")).select_by_visible_text( isoName) Select(driver.find_element_by_id("networkId")).select_by_visible_text( networkName) if assginIP is not None: driver.find_element_by_id("designIP").clear() driver.find_element_by_id("designIP").send_keys(assginIP) driver.find_element_by_id("create_btn").click() driver.find_element_by_xpath("(//button[@type='button'])[2]").click()
def add(driver, deliveryname, poolname, poolType, userNames): page.get_into_powerview(driver, '资源管理', '桌面交付组') driver.find_element_by_xpath("//*[@id='react_desk_add']").click() time.sleep(1) driver.find_element_by_id("inputName").clear() driver.find_element_by_id("inputName").send_keys(deliveryname) Select(driver.find_element_by_id( "desktopPoolIds")).select_by_visible_text(poolname + "(" + poolType.value + ")") for userName in userNames: driver.find_element_by_link_text(u"添加").click() driver.find_element_by_id("userName").clear() driver.find_element_by_id("userName").send_keys(userName) driver.find_element_by_xpath( u"//*[@id='popCurrent']//input[@value='查询']").click() time.sleep(1) driver.find_element_by_xpath( "//*[@id='user_table_info']//td[text()='" + userName + "']/ancestor::tr[1]//input").click() driver.find_element_by_xpath(constant.OKBUTTONPATH).click() driver.find_element_by_id("submit_but").click() driver.find_element_by_xpath(constant.OKBUTTONPATH).click()