def add(driver, contactName, contactEmail, isStar, contactPhone, contactComment): try: # 创建主页实例对象 hp = HomePage(driver) # 点击通讯录连接 hp.addressLink().click() time.sleep(3) # 创建添加联系人实例对象 apd = AddressBookPage(driver) apd.createContactPersonButton().click() if contactName: # 非必填项 apd.contactPersonName().send_keys(contactName) # 非必填项 apd.contactPersonEmail().send_keys(contactEmail) if isStar == u"是": # 非必填项 apd.starContacts().click() if contactPhone: # 非必填项 apd.contactPersonMobile().send_keys(contactPhone) if contactComment: apd.contactPersonComment().send_keys(contactComment) apd.saveContacePerson().click() except Exception as e: print(traceback.print_exc()) raise e
def add(driver, contactName, contactEmail, isStar, contactPhone, contactComment): try: #创建主页实例 hp = HomePage(driver) hp.addressLink().click() time.sleep(3) #创建联系人页面实例对象 apb = AddressBookPage(driver) apb.createContactPersonButton().click() if contactName: #非必输项 apb.contactPersonName().send_keys(contactName) #必输项 apb.contactPersonEmail().send_keys(contactEmail) if isStar == u"是": apb.starContacts().click() if contactPhone: apb.contactPersonMoblie().send_keys(contactPhone) if contactComment: apb.contactPersonComment().send_keys(contactComment) apb.saveContacePerson().click() except Exception, e: print traceback.print_exc() raise e
def addressLink(driver): ''' 点击通讯录按钮 :param driver: :return: ''' homePage = HomePage(driver) # 点击通讯录 homePage.addressLink().click()
def add(driver,contactName,contactEmail,isStar,contactPhone,contactComment): try: hp = HomePage(driver) hp.addressLink().click() time.sleep(3) apb = AddressBookPage(driver) apb.creatContactPersonButton().click() if contactName: apb.contactPersonName().send_keys(contactName) apb.contactPersonEmail().send_keys(contactEmail) if isStar == u"是": apb.starContacts().click() if contactPhone: apb.contactPersonMobile().send_keys(contactPhone) if contactComment: apb.contactPersonComment().send_keys(contactComment) apb.saveContacePerson().click() except Exception as e: print(traceback.print_exc()) raise e
def add(driver, contactName, contactEmail, isStar, contactPhone, contactComment): try: #创建主页实例对象 hp = HomePage(driver) time.sleep(3) # 单击通讯录链接 hp.addressLink().click() time.sleep(3) # 创建添加联系人页实例对象 apb = AddressBookPage(driver) apb.createContactPersonButton().click() if contactName: #非必填项 apb.contactPersonName().send_keys(contactName) if contactEmail: #必填项 apb.contactPersonEmail().send_keys(contactEmail) if isStar == u"是": # 非必填项 time.sleep(3) apb.starContacts().click() if contactPhone: # 非必填项 apb.contactPersonMobile().send_keys(contactPhone) if contactComment: time.sleep(3) print("输入comment") apb.contactPersonComment().send_keys(contactComment) # 点击保存 apb.saveContactPerson().click() except Exception as e: # 打印堆栈异常信息 print(traceback.print_exc()) raise e
def add(driver, contactName, contactEmail, isStar, contactPhone, contactComment): try: # 创建主页实例对象 hp = HomePage(driver) hp.addressLink().click() time.sleep(3) # 创建添加联系人页实例对象 apb = AddressBookPage(driver) apb.createContactPersonButton().click() time.sleep(3) if contactName: apb.contactPersonName().send_keys(contactName) apb.contactPersonEmail().send_keys(contactEmail) if isStar == u"是": apb.starContacts().click() if contactPhone: apb.contactPersonMobile().send_keys(contactPhone) if contactComment: apb.contactPersonComment().send_keys(contactComment) apb.saveContactPerson().click() except Exception, e: raise e
element = getElement(self.driver, by, locator) return element if __name__ == '__main__': from selenium import webdriver import time from pageObjects.HomePage import HomePage from appModules.LoginAction import LoginAction driver = webdriver.Firefox() driver.get('https://mail.126.com') time.sleep(3) # 登录 LoginAction.login(driver, 'linux', 'chao') # 主页面 homepage = HomePage(driver) homepage.addressLink().click() time.sleep(5) # 添加联系人页面 addcontact = AddContactPage(driver) addcontact.newContact().click() time.sleep(2) addcontact.addName().send_keys('test') addcontact.addMail().send_keys('*****@*****.**') addcontact.addPhone().send_keys('13691579846') addcontact.addContent().send_keys('ceshi') addcontact.markStar().click() time.sleep(3) addcontact.clickCommitBtn().click()