class VesyncLoginPage(BasePage): yaml_file, page = "VesyncLoginPage.yaml", "LoginPage" loc1 = get_locator(yaml_file, page, "用户名输入框") loc2 = get_locator(yaml_file, page, "密码输入框") loc3 = get_locator(yaml_file, page, "授权按钮") loc4 = get_locator(yaml_file, page, "授权成功的文案") def username_input(self, username): self.send_keys(self.loc1, username) def password_input(self, password): self.send_keys(self.loc2, password) def click_authorize(self): self.click(self.loc3) def authorize_success_text(self): return self.get_text(self.loc4) def action(self, username, password): self.username_input(username) self.password_input(password) self.click_authorize() time.sleep(3)
class AlexaLoginPage(BasePage): log = Log() yaml_file, page = "AlexaLoginPage.yaml", "AmazonAlexaLoginPage" loc1 = get_locator(yaml_file, page, "用户名输入框") loc2 = get_locator(yaml_file, page, "密码输入框") loc3 = get_locator(yaml_file, page, "sign-in按钮") def username_input(self, username): self.send_keys(self.loc1, username) def password_input(self, password): self.send_keys(self.loc2, password) def click_sign_in(self): self.click(self.loc3) def action(self, username, password): self.username_input(username) self.log.info("输入用户名") self.password_input(password) self.log.info("输入密码") self.log.info("准备点击登录") self.click_sign_in() self.log.info("点击登录了")
class AlexaSkillsPage(BasePage): yaml_file, page = "AlexaSkillsPage.yaml", "AlexaSkillsPage" loc1 = get_locator(yaml_file, page, "DEV_SKILLS") loc2 = get_locator(yaml_file, page, "vesync_testOnline") loc2_1 = get_locator(yaml_file, page, "") loc3 = get_locator(yaml_file, page, "vesync_pre_deploy_english_en") loc4 = get_locator(yaml_file, page, "是否绑定的文案提示") loc5 = get_locator(yaml_file, page, "enable按钮") loc6 = get_locator(yaml_file, page, "disable按钮") loc7 = get_locator(yaml_file, page, "discover_devices_button") loc8 = get_locator(yaml_file, page, "discover_button") loc9 = get_locator(yaml_file, page, "关闭弹框") def click_dev_skills(self): self.click(self.loc1) def click_vesync_test_online(self): self.click(self.loc2) def click_vesync_pre_deploy_english_en(self): self.click(self.loc3) def status_text(self): text = self.get_text(self.loc4) return text def click_enable_button(self): self.click(self.loc5) def click_disable_button(self): # 点击 Disable Skill按钮,解绑 self.click(self.loc6) def click_discover_devices_button(self): self.click(self.loc7) def discover_button(self): self.find_element(self.loc8) def discover_text(self): return self.get_text(self.loc7) def click_clone_button(self): self.click(self.loc9) def click_vesync_testonline_action(self): self.click_dev_skills() self.click_vesync_test_online() def click_vesync_pred_action(self): self.click_dev_skills() self.click_vesync_pre_deploy_english_en()
class SearchPage(BasePage): yaml_file, page = "baiduPage.yaml", "SearchPage" loc1 = get_locator(yaml_file, page, "百度搜索框") loc2 = get_locator(yaml_file, page, "百度一下按钮") loc3 = get_locator(yaml_file, page, "第一条结果") def search_input(self, text): self.send_keys(self.loc1, text) def click_search_button(self): self.click(self.loc2) def action(self, text): self.search_input(text) time.sleep(3) self.click_search_button() time.sleep(5) self.click(self.loc3) time.sleep(5)
class AlexaHomePage(BasePage): log = Log() yaml_file, page = "AlexaHomePage.yaml", "AlexaHomePage" loc1 = get_locator(yaml_file, page, "Skills") loc2 = get_locator(yaml_file, page, "YourSkills") def skill_text(self): return self.get_text(self.loc1) def click_skills(self): self.click(self.loc1) def click_you_skills(self): self.click(self.loc2) def action(self): self.log.info("登录成功,进入首页") self.click_skills() self.log.info("点击了skill") self.click_you_skills() self.log.info("点击了your skill")