def modify_sorcing(): lo = login_init.loginpage() so = Sourcing_init.sourcing() det = Pm_affiliateDetail.affiliatedetail() chromedriver = "D:\Program Files (x86)\Chrome\chromedriver.exe" os.environ["webdriver.chrome.driver"] = chromedriver browser = webdriver.Chrome(chromedriver) # Get local session of firefox browser.maximize_window() browser.get("http://192.168.1.20:9999") # Load page assert "login" in browser.title browser.implicitly_wait(2) Means.login(browser, "*****@*****.**", "123456") assert "System Integration" in browser.title lo.rolechosered(browser).click() time.sleep(2) so.sour(browser).click() time.sleep(1) status = so.tabstatus(browser).text if status == "Converted": print "此sourcing的状态为Converted,其详情页面不能编辑!" browser.quit() # 不能编辑,退出脚本 else: so.tableone(browser).click() le = det.LegalName(browser).text #############修改Legal Name字段################ det.LegalName(browser).clear() det.LegalName(browser).send_keys("modifyitsname01") name = det.LegalName(browser).text det.sosave(browser).click() #############确认是否修改成功###################### if le == name: print (le + "更改成了:modifyitsname" + ",此处没有Bug,成功修改!") testlog.logsys("此处没有BUG", "---没有BUG") else: print (le + "没有被修改,此处有BUG,请开发人员修改!---BUG") # 此处要是能做成那种发现bug,自动发送邮件给开发人员就Perfect了! browser.get_screenshot_as_file("D:/svn_QA/Screeshot/modifysourname.jpg") emailimage.AutoSendMail( u"修改sourcing页面的legal Name---此处有BUG,且附件是发送异常时的截图!请参考。" + "\n" + "感谢指导", "D:\\svn_QA\Screeshot\modifysourname.jpg", ) browser.close()
def sourcing_search(): a=['*****@*****.**','*****@*****.**','*****@*****.**'] Uname=["$%^&&&","45611%^","dad&^"] lo=login_init.loginpage() so=Sourcing_init.sourcing() Un=Pm_affiliate_search.affiliatesearch() chromedriver="D:\Program Files (x86)\Chrome\chromedriver.exe" os.environ["webdriver.chrome.driver"] = chromedriver browser = webdriver.Chrome(chromedriver) # Get local session of firefox browser.maximize_window() browser.get("http://192.168.1.20:9999") # Load page assert "login" in browser.title browser.implicitly_wait(2) Means.login(browser, '*****@*****.**', '123456') assert "System Integration" in browser.title lo.rolechosered(browser).click() time.sleep(2) so.sour(browser).click() time.sleep(1) Un.affiliateSearchfunction(browser).click() Un.Searchaffiliatename(browser).send_keys("@#$^&*^") time.sleep(1) Un.searchbutton(browser).click() ndata=Un.shownodata(browser).text if ndata=="No Data": print "输入特殊字符@¥@¥¥,返回值为No Data,此处没有BUG" Result_te.rest("输入特殊字符@¥@¥¥,返回值为No Data,此处没有BUG") else: print"输入特殊字符@#¥¥,返回值应为No Data!---此处有BUG" browser.get_screenshot_as_file("D:/svn_QA/Screeshot/sourcingsearch.jpg") # Sendemail.send_mail(a,'ting Auto test',u'输入特殊字符@#¥¥,返回值应为No Data!---此处有BUG') emailimage.AutoSendMail(u"输入特殊字符@#¥¥,返回值应为No Data!---此处有BUG,且附件是发送异常时的截图!请参考。"+"\n"+"感谢指导","D:\\svn_QA\Screeshot\sourcingsearch.jpg") testlog.logsys("输入特殊字符@#¥¥,返回值应为No Data!---此处有BUG", "---有BUG") Result_te.rest("输入特殊字符@#¥¥,返回值应为No Data!---此处有BUG") browser.close() #sourcing_search()
def newaffiliate(self): getrole = login_init.loginpage() getaffiliate = Pm_affiliate_search.affiliatesearch() affiliatedetail = Pm_affiliateDetail.affiliatedetail() chromedriver = "D:\Program Files (x86)\Chrome\chromedriver.exe" os.environ["webdriver.chrome.driver"] = chromedriver browser = webdriver.Chrome(chromedriver) # Get local session of firefox browser.maximize_window() try: browser.get("http://192.168.1.20:9999") # Load page assert "login" in browser.title browser.implicitly_wait(2) Means.login(browser, "*****@*****.**", "123456") assert "System Integration" in browser.title getrole.rolechosecm(browser).click() assert "http://192.168.1.20:9999/affiliate/cm/dashboard_index.html" in browser.current_url getaffiliate.affiliatesearchlist(browser).click() assert "Affiliate List" in browser.title time.sleep(1) getaffiliate.affiliateNew(browser).click() assert "http://192.168.1.20:9999/affiliate/CommonPages/affiliate_create.html" in browser.current_url affiliatedetail.LegalName(browser).send_keys("element test") affiliatedetail.DBAname(browser).send_keys("DBA Name") affiliatedetail.EntityType(browser).click() time.sleep(1) affiliatedetail.EntityTypeLLP(browser).click() assert "LLP" in affiliatedetail.EntityTypeLLP(browser).text affiliatedetail.State(browser).click() time.sleep(1) affiliatedetail.StateAS(browser).click() except Exception as e: print e msg = traceback.format_exc() testlog.logsys("运行失败", "控件没找到!" + msg) browser.close()
def nessouring(): chromedriver="D:\Program Files (x86)\Chrome\chromedriver.exe" os.environ["webdriver.chrome.driver"] = chromedriver browser = webdriver.Chrome(chromedriver) # Get local session of firefox browser.maximize_window() browser.get("http://192.168.1.20:9999") # Load page assert "login" in browser.title browser.implicitly_wait(2) Means.login(browser, '*****@*****.**', '123456') #登录pm time.sleep(2)# Let the page load, will be added to the API try: browser.find_element_by_xpath("//div[@class='pm tile double icon bg-color-redCustorm']/div/img").click() #using xpath to find element time.sleep(2) browser.find_element_by_xpath("//ul[@id='menu']/li/a").click()#click sourcing time.sleep(1) browser.find_element_by_id("btnSearchNew").click() # r=random.randint(1,1000) # print r browser.find_element_by_id("LegalName").send_keys(test.name[2]) browser.find_element_by_xpath("//div[@id='entityType']/div").click() time.sleep(2) entitytype=browser.find_element_by_xpath("//div[@id='entityType']/div[2]/ul/li[3]") print "输出entitytype:%s" %(entitytype.text) entitytype.click() #drop list chosen time.sleep(2) browser.find_element_by_xpath("//div[@id='stateRegistered']/div").click() time.sleep(2) statere=browser.find_element_by_xpath("//div[@id='stateRegistered']/div[2]/ul/li[7]") statere.click() browser.find_element_by_xpath("//input[@id='OfficePhoneAreaCode']").send_keys(test.times[1]) browser.find_element_by_xpath("//input[@id='OfficePhoneCentralOfficeCode']").send_keys(test.times[2]) browser.find_element_by_xpath("//input[@id='OfficePhoneStationCode']").send_keys("1881") browser.find_element_by_xpath("//input[@id='ContactOfficeAreaCode']").send_keys("545") browser.find_element_by_xpath("//input[@id='ContactOfficeCentralOfficeCode']").send_keys(test.times[1]) browser.find_element_by_xpath("//input[@id='ContactOfficeStationCode']").send_keys("3363") browser.find_element_by_id("SearchButton").click() if test.name[2]=='test01' and entitytype.text=='Corporation' and statere.text=='California(CA)': alerts=browser.find_element_by_id("alertSearch") print "alert的提示信息是否为:This affiliate already exists in the system ! --- %s" %(alerts.text) browser.find_element_by_id("LegalName").send_keys('Simpleok!') time.sleep(1) browser.find_element_by_id("SearchButton").click() time.sleep(1) else: newbutton=browser.find_element_by_id("NewLeadButton") if newbutton.is_displayed(): print "newbutton显示出来了,直接点击按钮New Lead即可!" time.sleep(1) browser.find_element_by_id("NewLeadButton").click() else: print"存在相同的phone #或者是office #,需重新填写phone # 或者Office #,需重新填写;" browser.find_element_by_xpath("//input[@id='OfficePhoneAreaCode']").clear() time.sleep(1) browser.find_element_by_xpath("//input[@id='OfficePhoneAreaCode']").send_keys('829') browser.find_element_by_xpath("//input[@id='OfficePhoneCentralOfficeCode']").clear() browser.find_element_by_xpath("//input[@id='OfficePhoneCentralOfficeCode']").send_keys("739") browser.find_element_by_xpath("//input[@id='OfficePhoneStationCode']").clear() browser.find_element_by_xpath("//input[@id='OfficePhoneStationCode']").send_keys("1584") browser.find_element_by_xpath("//input[@id='ContactOfficeAreaCode']").clear() browser.find_element_by_xpath("//input[@id='ContactOfficeAreaCode']").send_keys("981") browser.find_element_by_id("SearchButton").click() time.sleep(1) browser.find_element_by_id("NewLeadButton").click() time.sleep(1) print "检查当前页面的URL:http://192.168.1.20:9999/affiliate/pm/sourcing_detail.html ! ---%s " %(browser.current_url) browser.find_element_by_xpath("html/body/form/div[1]/div[1]/button[1]").click() save_alert=browser.find_element_by_xpath("html/body/div[1]") if save_alert.is_displayed(): print"save_alert被显示了!显示内容为:Please fill out all mandatory fields!f --- %s "%(save_alert.text) else: print"save_alert没有显示!! <此处有BUG>" time.sleep(1) browser.find_element_by_id("DBAName").send_keys("dba") time.sleep(1) browser.find_element_by_id("Address_AddressLine1").send_keys("line1") browser.find_element_by_id("Address_City").send_keys("city") browser.find_element_by_xpath("//div[@id='Address_State']/div").click() time.sleep(2) browser.find_element_by_xpath("//div[@id='Address_State']/div[2]/ul/li[3]").click() browser.find_element_by_id("Address_Zipcode").send_keys("12345") browser.find_element_by_id("Address_Country").send_keys("USA") browser.find_element_by_id("copyAddress").click() time.sleep(1) browser.find_element_by_xpath("//div[@id='ContactList']/div/div[2]/ul/li/div/input").send_keys("liui") browser.find_element_by_xpath("//div[@id='ContactList']/div/div[2]/ul[2]/li/div/input").send_keys("lting") browser.implicitly_wait(2) browser.find_element_by_xpath("//div[@id='ContactList']/div/div[2]/ul[2]/li[3]/div/input[2]").send_keys("123") browser.find_element_by_xpath("//div[@id='ContactList']/div/div[2]/ul[2]/li[3]/div/input[3]").send_keys("183") browser.find_element_by_xpath("//div[@id='ContactList']/div/div[2]/ul[2]/li[3]/div/input[4]").send_keys("1239") time.sleep(1) browser.find_element_by_id("MBECertified_CheckApplicable").click() browser.find_element_by_id("SelfPerformingCrews").send_keys("4") browser.find_element_by_id("SubContractedCrews").send_keys("4") #browser.find_element_by_xpath("//div[@id='ServiceTypes']/div").click browser.find_element_by_xpath("//ul[@id='Services']/li/div/p/span").click() time.sleep(1) browser.find_element_by_id("btnAddService").click() time.sleep(1) services=browser.find_element_by_xpath("//div[@id='ServiceAreas']/div/div/p") if services.text=='Repair & Maintenance': print"选择的服务类型正确:Repair & Maintenance ---%s" %(services.text) browser.find_element_by_xpath("//div[@id='ServiceAreas']/div/div/a").click() time.sleep(1) browser.find_element_by_xpath("html/body/div[8]/div[3]/div/button[1]").click() ServiceArea=browser.find_element_by_id("ServiceTypeError") if ServiceArea.text=='At least one service type needs to be selected.': print"删除服务范围之后,应有提示语:%s ,显示正确;" %(ServiceArea.text) else: print"在没有选择任何服务区域的时候,应有提示信息显示:At least one service type needs to be selected.---此处有BUG!" else: print "应显示服务类型的名字:Repair & Maintenance---此处有BUG!" browser.find_element_by_xpath("//ul[@id='Services']/li/div/p/span").click() time.sleep(1) browser.find_element_by_id("btnAddService").click() browser.implicitly_wait(2) browser.find_element_by_xpath("//div[@id='ServiceAreas']/div[1]/div[2]/div[1]/div[2]/ul/li/input").send_keys("12345") browser.find_element_by_xpath("//div[@id='ServiceAreas']/div[1]/div[2]/div[1]/div[2]/ul/li[2]/input").send_keys("12") browser.find_element_by_xpath("//div[@id='ServiceAreas']/div[1]/div[2]/div[1]/div[2]/ul/li[3]/input").send_keys("12") browser.find_element_by_xpath("//div[@id='ServiceAreas']/div[1]/div[2]/div[1]/div[2]/ul/li[4]/input").send_keys("12") browser.find_element_by_xpath("//div[@id='ServiceAreas']/div[1]/div[2]/div[1]/div[3]/ul/li[1]/input").send_keys("2") browser.find_element_by_xpath("//div[@id='ServiceAreas']/div[1]/div[2]/div[1]/div[3]/ul/li[2]/input").send_keys("1") browser.find_element_by_xpath("//div[@id='ServiceAreas']/div[1]/div[2]/div[1]/div[3]/ul/li[3]/input").send_keys("12") browser.find_element_by_xpath("//div[@id='ServiceAreas']/div[1]/div[2]/div[1]/div[3]/ul/li[4]/input").send_keys("12") time.sleep(1) browser.find_element_by_xpath("//body/form/div[1]/div[6]/button").click() time.sleep(1) browser.find_element_by_xpath("//body/form/div[1]/div/button[2]").click() time.sleep(2) browser.find_element_by_xpath("//html/body/div[8]/div[3]/div/button[1]").click() #browser.close() # except : # testlog.logsys("运行失败", "控件没找到!") except Exception as e: print e msg = traceback.format_exc() testlog.logsys("运行失败", "控件没找到!"+ msg) browser.get_screenshot_as_file("D:/svn_QA/Screeshot/NewSourcing.jpg") # Sendemail.send_mail(a,'ting Auto test',u'输入特殊字符@#¥¥,返回值应为No Data!---此处有BUG') emailimage.AutoSendMail(u"新增sourcing时失败!---此处有BUG,且附件是发送异常时的截图!请参考。"+"\n"+"感谢指导!","D:\\svn_QA\Screeshot\NewSourcing.jpg")