def login(driver, url, username, password): login_page = LoginPage(driver) login_page.open_url(url) login_page.set_browser_max() login_page.input_username(username) login_page.input_password(password) login_page.click_login()
#操作 def get_companyname(self): #获取公司名称 value = self.get_text(self.companyname_shwbox) return value def go_myzone(self): #进入我的地盘 self.cilck(self.go_myzone()) def goto_product(self): #进入产品模块 self.cilck(self.go_myzone()) def get_username(self): #获取用户名 value = self.get_text(self.username_showspan) return value if __name__ == '__main__': webdriver_path = os.path.join(os.path.dirname(__file__), '..', 'webdriver', 'chromedriver.exe') driver = webdriver.Chrome(executable_path=webdriver_path) login_page = LoginPage(driver) login_page.open_url( 'http://47.107.178.45/zentao/www/index.php?m=user&f=login') login_page.set_browser_max() login_page.input_username('test01') login_page.input_password('newdream123') login_page.click_login() companyname = MainPage(driver).get_companyname() username = MainPage(driver).get_username() print(companyname) print(username)
self.click(self.edit_user_button) def click_deleteUser_button(self): self.delete_user_button['locator_value'] = self.delete_user_button[ 'locator_value'] % self.username_value self.click(self.delete_user_button) def switch_to_frame(self): self.switchToFrame(self.iframe) if __name__ == "__main__": driver = webdriver.Chrome() login_page = LoginPage(driver) login_page.open_url( 'http://106.53.50.202:8999/zentao4/www/user-login-L3plbnRhbzYvd3d3Lw==.html' ) login_page.set_browser_max() #登录系统 login_page.input_username('admin') login_page.input_password('admin@123') login_page.click_login() #来到用户页面 organization_page = OrganizationPage(driver) organization_page.click_organization_link() #点击一级菜单组织链接 organization_page.click_user_link() #新增用户 user_page = UserPage(driver) user_page.click_addUser_button() user_page.click_belongToDepartment_select() user_page.click_belongToDepartment_value()
def __init__(self, driver): super().__init__(driver) login_page = LoginPage(driver) login_page.open_url( 'http://106.53.50.202:8999/zentao2/www/my-managecontacts.html') login_page.input_username('hanruqing') login_page.input_password('Aa234567') login_page.click_login() # self.calendar_href={'element_name':'日程链接', # 'locator_type':'xpath', # 'locator_value':'//li[@data-id="calendar"]', # 'timeout':5 # } # self.manageContacts_href = {'element_name': '联系人链接', # 'locator_type': 'xpath', # 'locator_value': '//li[@data-id="manageContacts"]', # 'timeout': 5 # } # self.newList_inputbox = {'element_name': '列表名称输入框', # 'locator_type': 'xpath', # 'locator_value': '//input[@id="newList"]', # 'timeout': 5 # } # self.users_chosen_combobox = {'element_name': '用户选择下拉框', # 'locator_type': 'xpath', # 'locator_value': '//div[@id="users_chosen"]', # 'timeout': 5 # } # self.choose_users_box = {'element_name': '选择用户', # 'locator_type': 'xpath', # 'locator_value': '//li[@title="陈江林"]', # 'timeout': 5 # } # self.save_button = {'element_name': '保存列表按钮', # 'locator_type': 'xpath', # 'locator_value': '//button[@id="submit"]', # 'timeout': 5 # } # self.delete_button = {'element_name': '删除列表按钮', # 'locator_type': 'xpath', # 'locator_value': '//a[@class="btn btn-danger btn-wide"]', # 'timeout': 5 # } # self.changepasswd_href={'element_name':'修改密码链接', # 'locator_type':'xpath', # 'locator_value':'//li[@data-id="changePassword"]', # 'timeout':5} # self.originalpasswd_inputbox={'element_name':'原始密码输入框', # 'locator_type':'xpath', # 'locator_value':'//input[@id="originalPassword"]', # 'timeout':5} # self.newpasswd_inputbox1 = {'element_name': '新密码输入框1', # 'locator_type': 'xpath', # 'locator_value': '//input[@id="password1"]', # 'timeout': 5} # self.newpasswd_inputbox2 = {'element_name': '新密码输入框2', # 'locator_type': 'xpath', # 'locator_value': '//input[@id="password2"]', # 'timeout': 5} # self.savepasswd_button = {'element_name': '密码保存按钮', # 'locator_type': 'xpath', # 'locator_value': '//button[@id="submit"]', # 'timeout': 5} elements = ElementdataUtils('myzone_page').get_element_info() # elements=ElementdataUtilsYaml().get_element_info_by_yaml() self.manageContacts_href = elements['manageContacts_href'] self.newList_inputbox = elements['newList_inputbox'] self.users_chosen_combobox = elements['users_chosen_combobox'] self.choose_users_box = elements['choose_users_box'] self.save_button = elements['save_button'] self.changepasswd_href = elements['changepasswd_href'] self.originalpasswd_inputbox = elements['originalpasswd_inputbox'] self.newpasswd_inputbox1 = elements['newpasswd_inputbox1'] self.newpasswd_inputbox2 = elements['newpasswd_inputbox2'] self.savepasswd_button = elements['savepasswd_button']