def test_mycomment_03(self): '''删除发出的评论''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[4]/a/strong").click() time.sleep(2) self.assertEqual("我的评论",driver.find_element_by_xpath("/html/body/div/div/div[2]/div[1]/div/div/div/span").text) driver.find_element_by_xpath("//div[2]/div/div/ul/li[2]/a").click() time.sleep(2) del_before = driver.find_element_by_xpath("/html/body/div/div/div[2]/div[2]/div/table/tbody/tr[1]/td/div[1]/span[1]").text driver.find_element_by_xpath("//a[contains(text(),'删除')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'取消')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'删除')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'确定')]").click() time.sleep(2) del_after = driver.find_element_by_xpath("/html/body/div/div/div[2]/div[2]/div/table/tbody/tr[1]/td/div[1]/span[1]").text if del_after != del_before: print u"删除成功!目前最新的评论内容是:%s"%del_after else: print u"删除失败!" user.quit(self)
def test_mycomment_02(self): '''编辑发出的评论''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[4]/a/strong").click() time.sleep(2) self.assertEqual("我的评论",driver.find_element_by_xpath("/html/body/div/div/div[2]/div[1]/div/div/div/span").text) driver.find_element_by_xpath("//div[2]/div/div/ul/li[2]/a").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'编辑')]").click() time.sleep(2) driver.find_element_by_xpath("//*[@id='commentText']").clear() nowtime = time.ctime() driver.find_element_by_xpath("//*[@id='commentText']").send_keys(u"编辑发出的评论%s"%nowtime) #time.sleep(2) driver.find_element_by_xpath("//*[@id='editCommentOk']").click() time.sleep(2) self.assertEqual(u"编辑发出的评论%s"%nowtime,driver.find_element_by_xpath("/html/body/div/div/div[2]/div[2]/div/table/tbody/tr[1]/td/div[1]/span[1]").text) print u"修改成功!" user.quit(self)
def test_project_status_5(self): '''修改项目''' driver = self.driver user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) #筛选状态为实现中的项目,修改第一个项目 driver.find_element_by_id("statusFilter").click() time.sleep(0.5) filt = driver.find_element_by_id("mainStatusChange") time.sleep(1) filt.find_element_by_xpath("//option[@value='0']").click() time.sleep(1) driver.find_element_by_xpath("//td[3]/a").click() time.sleep(2) driver.find_element_by_xpath("//input[@value='修改']").click() time.sleep(2) driver.find_element_by_id("targetName").clear() driver.find_element_by_id("targetName").send_keys(u"修改项目名称_%s"%time.strftime("%Y%m%d_%H%M%S",time.localtime())) time.sleep(2) driver.find_element_by_id("editTargetReason").clear() driver.find_element_by_id("editTargetReason").send_keys(u"修改理由@%s"%time.ctime()) time.sleep(2) driver.find_element_by_id("submitAdd").click() time.sleep(1) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id("confirmOk").click() print u"修改成功!修改理由@%s"%time.ctime() time.sleep(2) user.quit(self)
def test_project_info_1(self): """新建协商""" driver = self.driver project_info(self) driver.find_element_by_xpath("//a[contains(text(),'协商')]").click() time.sleep(1) driver.find_element_by_id("realname").click() time.sleep(2) now = time.strftime("%Y%m%d_%H%M%S", time.localtime()) driver.find_element_by_id("title").send_keys(u"新建协商主题_%s" % now) time.sleep(2) f2 = driver.find_element_by_xpath("//span/table/tbody/tr[2]/td/iframe") driver.switch_to_frame(f2) driver.find_element_by_xpath("//*[@id='tinymce']").send_keys(u"协商内容@%s" % time.ctime()) driver.switch_to_default_content() pub.switchtoframe(self) driver.find_element_by_link_text(u"上传附件").click() time.sleep(1) driver.find_element_by_xpath("//input[@name='0']").send_keys( "D:\\work\\mgt_webtest\\data\\know_commentContent.txt" ) time.sleep(3) driver.find_element_by_xpath("//*[@id='connsubmit']").click() time.sleep(2) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id("confirmOk").click() time.sleep(2) title = driver.find_element_by_xpath("//table/tbody/tr[2]/td[2]/div[1]/a") self.assertEqual(u"新建协商主题_%s" % now, title.text) print u"新建协商成功!标题为:新建协商主题_%s" % now user.quit(self)
def test_project_status_3(self): '''撤销项目''' driver = self.driver driver.get(self.base_url)# + "/mgt/frame.jsp?url=MGT_PROJECT_MY") user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) #筛选状态为进行中的项目,撤销列表中的第一个项目 driver.find_element_by_id("statusFilter").click() time.sleep(0.5) filt = driver.find_element_by_id("mainStatusChange") time.sleep(1) filt.find_element_by_xpath("//option[@value='0']").click() time.sleep(1) pro_name = driver.find_element_by_xpath("//td[3]/a") #pro_name.text pro_name.click() time.sleep(2) #点击撤销按钮 driver.find_element_by_xpath("//div[3]/div/div[2]/span").click() time.sleep(2) cancelReason = driver.find_element_by_id("MgtPopup-Popup") cancelReason.find_element_by_id("reason").clear() cancelReason.find_element_by_id("reason").send_keys(u"项目需要撤销!") time.sleep(2) cancelReason.find_element_by_xpath("//input[@value='提交']").click() time.sleep(1) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id("confirmOk").click() time.sleep(2) driver.find_element_by_id("mgtAlertDivId").find_element_by_id("buttonOk").click() time.sleep(1) print u"项目已撤销!" user.quit(self)
def test_todaylog_08(self): '''预览附件''' driver = self.driver driver.get( self.base_url) # + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) nowhandle = driver.current_window_handle driver.find_element_by_xpath("//a[contains(text(),'预览')]").click() time.sleep(2) allhandles = driver.window_handles for handle in allhandles: if handle != nowhandle: driver.switch_to_window(handle) time.sleep(2) driver.get_screenshot_as_file( "D:\\work\\mgt_webtest\\screenshot\\dayplan_attachpreview%s.png" % time.strftime("%Y%m%d_%H%M%S", time.localtime())) print u"预览成功,截图在screenshot目录下!" driver.close() driver.switch_to_window(nowhandle) time.sleep(3) user.quit(self)
def test_project_info_2(self): """添加文档""" driver = self.driver project_info(self) driver.find_element_by_link_text(u"文档").click() time.sleep(2) driver.find_element_by_id("realname").click() time.sleep(2) now = time.strftime("%Y%m%d_%H%M%S", time.localtime()) driver.find_element_by_id("title").send_keys(u"添加文档_%s" % now) driver.find_element_by_link_text(u"上传附件").click() time.sleep(2) driver.find_element_by_link_text(u"删除").click() time.sleep(2) driver.find_element_by_link_text(u"上传附件").click() driver.find_element_by_xpath("//input[@type='file']").send_keys( "D:\\work\\mgt_webtest\\data\\know_commentContent.txt" ) time.sleep(2) driver.find_element_by_id("connsubmit").click() time.sleep(2) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id("confirmOk").click() time.sleep(2) title = driver.find_element_by_xpath("//div[2]/div[2]/div[2]/table/tbody/tr[2]/td[2]") title.text self.assertEqual(u"添加文档_%s" % now, title.text) print u"添加文档成功!标题为:添加文档_%s" % now user.quit(self)
def test_todaylog_03(self): '''删除日计划''' driver = self.driver driver.get( self.base_url) # + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//td[3]/a/i").click() time.sleep(1) dayplan_del = driver.find_element_by_id( "myModalDayPlan").find_element_by_id("btn_worklog_delete_dayPlan") dayplan_del.click() time.sleep(2) driver.find_element_by_xpath( "//a[contains(text(),'取消')]").click() #取消删除 time.sleep(1) dayplan_del.click() time.sleep(1) driver.find_element_by_xpath( "//a[contains(text(),'确定')]").click() #确认删除 time.sleep(2) print u"日计划删除成功!" user.quit(self)
def test_project_status_4(self): '''恢复项目''' driver = self.driver user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) #过滤为已撤销的项目,恢复列表中的第一个项目 driver.find_element_by_id("statusFilter").click() time.sleep(0.5) filt = driver.find_element_by_id("mainStatusChange") time.sleep(1) filt.find_element_by_xpath("//option[@value='1']").click() time.sleep(1) driver.find_element_by_xpath("//td[3]/a").click() time.sleep(2) #点击恢复按钮 driver.find_element_by_xpath("//div[2]/div/div[2]/span").click() time.sleep(2) resReason=driver.find_element_by_xpath("//*[@id='MgtPopup-Popup']") resReason.find_element_by_xpath("//*[@id='reason']").clear() driver.find_element_by_xpath("//*[@id='reason']").send_keys(u"恢复理由@%s"%time.ctime()) time.sleep(2) resReason.find_element_by_xpath("//input[@value='提交']").click() time.sleep(1) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id("confirmOk").click() time.sleep(2) driver.find_element_by_id("mgtAlertDivId").find_element_by_id("buttonOk").click() time.sleep(1) print u"项目已恢复!" user.quit(self)
def test_project_info_3(self): """编辑人员""" driver = self.driver project_info(self) driver.find_element_by_link_text(u"人员").click() time.sleep(2) driver.find_element_by_link_text(u"删除参与人").click() time.sleep(2) driver.find_element_by_id("reason_form").find_element_by_id("reason").send_keys(u"删除理由_%s" % pub.now()) time.sleep(3) driver.find_element_by_id("MgtPopup-Popup").find_element_by_xpath("//input[@value='提交']").click() time.sleep(2) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id("confirmOk").click() time.sleep(2) driver.find_element_by_id("buttonOk").click() time.sleep(2) driver.find_element_by_id("realname").click() time.sleep(2) driver.find_element_by_link_text(u"设置参与人").click() time.sleep(2) driver.find_element_by_id("userListSelectSelfInput").click() time.sleep(2) driver.find_element_by_id("userListSubmitButton").click() time.sleep(2) driver.find_element_by_id("addUserReason").send_keys(u"编辑人员原因:%s" % pub.now()) time.sleep(2) driver.find_element_by_id("submitAdd").click() time.sleep(2) driver.find_element_by_id("confirmOk").click() print u"修改成功!" time.sleep(2) user.quit(self)
def test_viewlog_02(self): '''编辑评阅日志''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[5]/a/strong").click() time.sleep(2) self.assertEqual("评阅日志",driver.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[1]/div/span").text) driver.find_element_by_xpath("//div[@id='viewlogList']/table/tbody/tr/td/div").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'编辑')]").click() time.sleep(2) nowtime = time.ctime() driver.find_element_by_xpath("//*[@id='commentText']").clear() driver.find_element_by_xpath("//*[@id='commentText']").send_keys(u"编辑经理评阅日志@%s"%nowtime) print u"编辑评阅日志成功!编辑后的评论内容:编辑经理评阅日志@%s"%nowtime time.sleep(2) driver.find_element_by_xpath("//*[@id='editCommentOk']").click() time.sleep(2) self.assertEqual(u"编辑经理评阅日志@%s"%nowtime,driver.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[4]/div/div/div[6]/div/table/tbody/tr[2]/td").text) user.quit(self) driver.close()
def test_project_info_1(self): '''新建协商''' driver = self.driver project_info(self) driver.find_element_by_xpath("//a[contains(text(),'协商')]").click() time.sleep(1) driver.find_element_by_id("realname").click() time.sleep(2) now = time.strftime("%Y%m%d_%H%M%S", time.localtime()) driver.find_element_by_id("title").send_keys(u"新建协商主题_%s" % now) time.sleep(2) f2 = driver.find_element_by_xpath("//span/table/tbody/tr[2]/td/iframe") driver.switch_to_frame(f2) driver.find_element_by_xpath("//*[@id='tinymce']").send_keys( u"协商内容@%s" % time.ctime()) driver.switch_to_default_content() pub.switchtoframe(self) driver.find_element_by_link_text(u"上传附件").click() time.sleep(1) driver.find_element_by_xpath("//input[@name='0']").send_keys( "D:\\work\\mgt_webtest\\data\\know_commentContent.txt") time.sleep(3) driver.find_element_by_xpath("//*[@id='connsubmit']").click() time.sleep(2) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id( "confirmOk").click() time.sleep(2) title = driver.find_element_by_xpath( "//table/tbody/tr[2]/td[2]/div[1]/a") self.assertEqual(u"新建协商主题_%s" % now, title.text) print u"新建协商成功!标题为:新建协商主题_%s" % now user.quit(self)
def test_project_info_2(self): '''添加文档''' driver = self.driver project_info(self) driver.find_element_by_link_text(u"文档").click() time.sleep(2) driver.find_element_by_id("realname").click() time.sleep(2) now = time.strftime("%Y%m%d_%H%M%S", time.localtime()) driver.find_element_by_id("title").send_keys(u"添加文档_%s" % now) driver.find_element_by_link_text(u"上传附件").click() time.sleep(2) driver.find_element_by_link_text(u"删除").click() time.sleep(2) driver.find_element_by_link_text(U"上传附件").click() driver.find_element_by_xpath("//input[@type='file']").send_keys( "D:\\work\\mgt_webtest\\data\\know_commentContent.txt") time.sleep(2) driver.find_element_by_id("connsubmit").click() time.sleep(2) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id( "confirmOk").click() time.sleep(2) title = driver.find_element_by_xpath( "//div[2]/div[2]/div[2]/table/tbody/tr[2]/td[2]") title.text self.assertEqual(u"添加文档_%s" % now, title.text) print u"添加文档成功!标题为:添加文档_%s" % now user.quit(self)
def test_project_status_2(self): '''激活项目''' driver = self.driver driver.get(self.base_url)# + "/mgt/frame.jsp?url=MGT_PROJECT_MY") user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) #筛选状态为已完成的项目,撤销第一个项目 driver.find_element_by_id("statusFilter").click() time.sleep(0.5) filt = driver.find_element_by_id("mainStatusChange") time.sleep(1) filt.find_element_by_xpath("//option[@value='2']").click() time.sleep(1) driver.find_element_by_xpath("//td[3]/a").click() time.sleep(2) #点击激活按钮 driver.find_element_by_xpath("//div[2]/div/div[2]/span").click() time.sleep(2) actReason=driver.find_element_by_xpath("//*[@id='MgtPopup-Popup']") actReason.find_element_by_xpath("//*[@id='reason']").clear() driver.find_element_by_xpath("//*[@id='reason']").send_keys(u"激活理由@%s"%time.ctime()) print u"项目已激活成功!" time.sleep(2) actReason.find_element_by_xpath("//input[@value='提交']").click() time.sleep(1) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id("confirmOk").click() time.sleep(2) driver.find_element_by_id("mgtAlertDivId").find_element_by_id("buttonOk").click() time.sleep(1) print u"项目已激活!" user.quit(self)
def test_project_info_4(self): '''新建子项目''' driver = self.driver project_info(self) driver.find_element_by_link_text(u"子项目").click() time.sleep(2) driver.find_element_by_id("realname").click() time.sleep(2) driver.find_element_by_id("targetName").send_keys(u"子项目名称_%s" % pub.now()) time.sleep(2) f1 = driver.find_element_by_xpath( "//table/tbody/tr[3]/td/div/span/table/tbody/tr[2]/td/iframe") driver.switch_to_frame(f1) driver.find_element_by_id("tinymce").send_keys(u"项目描述@%s" % pub.now()) driver.switch_to_default_content() pub.switchtoframe(self) driver.find_element_by_id("beginDateCheckBox").click() time.sleep(1) driver.find_element_by_id("endDateCheckBox").click() time.sleep(2) driver.find_element_by_id("submitAdd").click() time.sleep(2) driver.find_element_by_id("confirmOk").click() time.sleep(2) print u"子项目创建成功!" user.quit(self)
def test_project_status_5(self): '''修改项目''' driver = self.driver user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) #筛选状态为实现中的项目,修改第一个项目 driver.find_element_by_id("statusFilter").click() time.sleep(0.5) filt = driver.find_element_by_id("mainStatusChange") time.sleep(1) filt.find_element_by_xpath("//option[@value='0']").click() time.sleep(1) driver.find_element_by_xpath("//td[3]/a").click() time.sleep(2) driver.find_element_by_xpath("//input[@value='修改']").click() time.sleep(2) driver.find_element_by_id("targetName").clear() driver.find_element_by_id("targetName").send_keys( u"修改项目名称_%s" % time.strftime("%Y%m%d_%H%M%S", time.localtime())) time.sleep(2) driver.find_element_by_id("editTargetReason").clear() driver.find_element_by_id("editTargetReason").send_keys(u"修改理由@%s" % time.ctime()) time.sleep(2) driver.find_element_by_id("submitAdd").click() time.sleep(1) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id( "confirmOk").click() print u"修改成功!修改理由@%s" % time.ctime() time.sleep(2) user.quit(self)
def test_project_status_4(self): '''恢复项目''' driver = self.driver user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) #过滤为已撤销的项目,恢复列表中的第一个项目 driver.find_element_by_id("statusFilter").click() time.sleep(0.5) filt = driver.find_element_by_id("mainStatusChange") time.sleep(1) filt.find_element_by_xpath("//option[@value='1']").click() time.sleep(1) driver.find_element_by_xpath("//td[3]/a").click() time.sleep(2) #点击恢复按钮 driver.find_element_by_xpath("//div[2]/div/div[2]/span").click() time.sleep(2) resReason = driver.find_element_by_xpath("//*[@id='MgtPopup-Popup']") resReason.find_element_by_xpath("//*[@id='reason']").clear() driver.find_element_by_xpath("//*[@id='reason']").send_keys( u"恢复理由@%s" % time.ctime()) time.sleep(2) resReason.find_element_by_xpath("//input[@value='提交']").click() time.sleep(1) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id( "confirmOk").click() time.sleep(2) driver.find_element_by_id("mgtAlertDivId").find_element_by_id( "buttonOk").click() time.sleep(1) print u"项目已恢复!" user.quit(self)
def test_planlist_03(self): '''查询日计划''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[2]/a/strong").click() time.sleep(2) driver.find_element_by_css_selector("i.icon-calendar").click() driver.find_element_by_xpath( "/html/body/div[2]").find_element_by_xpath( "//tbody/tr[5]/td[5]").click() time.sleep(1) driver.find_element_by_xpath("//span[@id='dpYears2']/span/i").click() driver.find_element_by_xpath( "/html/body/div[3]").find_element_by_xpath( "//div[3]/div[3]/table/tbody/tr[5]/td[5]").click() time.sleep(1) driver.find_element_by_xpath("//button[@id='checkBtn']").click() time.sleep(2) print u"查询结果成功!" driver.find_element_by_xpath("//*[@id='resetBtn']").click() print u"查询时间已清空!" user.quit(self)
def test_mylog_02(self): '''查看日志详情''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath( "//a[contains(@href, 'mylog.do')]").click() time.sleep(2) driver.find_element_by_xpath( "//div[@id='containerDiv']/div/div[2]/div[3]/div/table/tbody/tr/td/div" ).click() time.sleep(2) logdetail = driver.find_element_by_xpath( "/html/body/div/div/div[2]/div[2]/div/div/h4") logdetail.text print u"您现在看到的日志是%s的日志" % logdetail.text driver.find_element_by_xpath("//div[3]/div/div/a").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'上一个')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'返回日志列表')]").click() time.sleep(2) user.quit(self)
def test_project_info_4(self): """新建子项目""" driver = self.driver project_info(self) driver.find_element_by_link_text(u"子项目").click() time.sleep(2) driver.find_element_by_id("realname").click() time.sleep(2) driver.find_element_by_id("targetName").send_keys(u"子项目名称_%s" % pub.now()) time.sleep(2) f1 = driver.find_element_by_xpath("//table/tbody/tr[3]/td/div/span/table/tbody/tr[2]/td/iframe") driver.switch_to_frame(f1) driver.find_element_by_id("tinymce").send_keys(u"项目描述@%s" % pub.now()) driver.switch_to_default_content() pub.switchtoframe(self) driver.find_element_by_id("beginDateCheckBox").click() time.sleep(1) driver.find_element_by_id("endDateCheckBox").click() time.sleep(2) driver.find_element_by_id("submitAdd").click() time.sleep(2) driver.find_element_by_id("confirmOk").click() time.sleep(2) print u"子项目创建成功!" user.quit(self)
def test_mylog_01(self): '''查看评阅日志权限人''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath( "//a[contains(@href, 'mylog.do')]").click() time.sleep(2) driver.find_element_by_xpath( "//a[contains(text(),'看看谁有权评阅您的日志')]").click() time.sleep(2) pingyue = driver.find_element_by_xpath("/html/body/div[4]/div[2]/div") pingyue.text print u"有权评阅您的日志的有:%s" % pingyue.text driver.get_screenshot_as_file( "D:\\work\\mgt_webtest\\screenshot\\permModalpeople%s" % time.strftime("%Y%m%d_%H%M%S", time.localtime())) time.sleep(2) driver.find_element_by_xpath( "//div[@id='permModal']/div[3]/button").click( ) #find_element_by_xpath('//*[@id="permModal"]'). user.quit(self)
def test_viewlog_03(self): '''删除评阅日志''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[5]/a/strong").click() time.sleep(2) self.assertEqual("评阅日志",driver.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[1]/div/span").text) driver.find_element_by_xpath("//div[@id='viewlogList']/table/tbody/tr/td/div").click() time.sleep(2) theFirstInfo = driver.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[4]/div/div/div[6]/div/table/tbody/tr[2]/td").text driver.find_element_by_xpath("//a[contains(text(),'删除')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'取消')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'删除')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'确定')]").click() time.sleep(2) #self.verifyEqual(theFirstInfo,driver.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[4]/div/div/div[6]/div/table/tbody/tr[2]/td").text) if theFirstInfo != driver.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[4]/div/div/div[6]/div/table/tbody/tr[2]/td").text: print u"删除成功!" print u"删除的评论内容是:%s"%theFirstInfo else: print u"删除失败" user.quit(self)
def test_viewlog_01(self): '''发布评阅日志''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[5]/a/strong").click() time.sleep(2) self.assertEqual( "评阅日志", driver.find_element_by_xpath( "/html/body/div[1]/div/div[2]/div[1]/div/span").text) driver.find_element_by_xpath( "//div[@id='viewlogList']/table/tbody/tr/td/div").click() time.sleep(2) #发布一条为空的评论,查看错误信息提示是否正确 driver.find_element_by_xpath("//*[@id='btnComment']").click() print u"%s" % driver.find_element_by_class_name("valid-error").text self.assertEqual(u"请输入评论内容或上传附件!", driver.find_element_by_class_name("valid-error").text) time.sleep(2) nowtime = time.ctime() driver.find_element_by_xpath("//*[@id='logComment']").send_keys( u"经理评阅日志@%s" % nowtime) time.sleep(2) driver.find_element_by_xpath("//*[@id='btnComment']").click() print u"经理评阅日志成功!内容为:经理评阅日志@%s" % nowtime time.sleep(2) driver.switch_to_default_content() driver.find_element_by_xpath("//a[contains(text(),'安全退出')]").click() time.sleep(2) #被评阅的员工查看经理发出的评阅信息 driver.get(self.base_url) user.login_a(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[4]/a/strong").click() time.sleep(2) self.assertEqual( "我的评论", driver.find_element_by_xpath( "/html/body/div/div/div[2]/div[1]/div/div/div/span").text) managerView = driver.find_element_by_xpath( "html/body/div/div/div[2]/div[2]/div/table/tbody/tr[1]/td/div[1]/span[1]" ) managerView.text self.assertEqual(u'经理评阅日志@%s' % nowtime, managerView.text) print u"员工可看到领导发布的评阅信息!" user.quit(self) driver.close()
def test_todaylog_09(self): '''查看访问记录''' driver = self.driver driver.get(self.base_url)# + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'访问记录')]").click() time.sleep(1) print u"访问记录查看成功!" user.quit(self)
def test_todaylog_15(self): '''查看本周计划''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'本周计划')]").click() driver.get_screenshot_as_file("D:\\work\\mgt_webtest\\screenshot\\worklogtoweekplan%s"%time.strftime("%Y%m%d_%H%M%S",time.localtime())) time.sleep(2) driver.find_element_by_xpath("//div[@id='modal4weekplan']/div/button").click()#//button[@type='button'])[2] user.quit(self)
def test_todaylog_09(self): '''查看访问记录''' driver = self.driver driver.get( self.base_url) # + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'访问记录')]").click() time.sleep(1) print u"访问记录查看成功!" user.quit(self)
def test_weibo_add(self): '''发微博''' driver = self.driver driver.get(self.base_url) time.sleep(3) user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_twitter").click() time.sleep(2) pub.switchtoframe(self) driver.find_element_by_xpath("//textarea").send_keys(u"测试,测试!%s"%time.ctime()) time.sleep(3) driver.find_element_by_xpath("//button[@type='button']").click() print u"微博发布!" user.quit(self)
def test_todaylog_11(self): '''发表评论''' driver = self.driver driver.get(self.base_url)#+ "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//*[@id='logComment']").send_keys(u"发表评论@%s"%time.ctime()) print u"发表评论内容为:发表评论@%s"%time.ctime() time.sleep(2) driver.find_element_by_xpath("//*[@id='btnComment']").click() time.sleep(3) user.quit(self)
def test_viewlog_01(self): '''发布评阅日志''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[5]/a/strong").click() time.sleep(2) self.assertEqual("评阅日志",driver.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[1]/div/span").text) driver.find_element_by_xpath("//div[@id='viewlogList']/table/tbody/tr/td/div").click() time.sleep(2) #发布一条为空的评论,查看错误信息提示是否正确 driver.find_element_by_xpath("//*[@id='btnComment']").click() print u"%s"%driver.find_element_by_class_name("valid-error").text self.assertEqual(u"请输入评论内容或上传附件!",driver.find_element_by_class_name("valid-error").text) time.sleep(2) nowtime = time.ctime() driver.find_element_by_xpath("//*[@id='logComment']").send_keys(u"经理评阅日志@%s"%nowtime) time.sleep(2) driver.find_element_by_xpath("//*[@id='btnComment']").click() print u"经理评阅日志成功!内容为:经理评阅日志@%s"%nowtime time.sleep(2) driver.switch_to_default_content() driver.find_element_by_xpath("//a[contains(text(),'安全退出')]").click() time.sleep(2) #被评阅的员工查看经理发出的评阅信息 driver.get(self.base_url) user.login_a(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[4]/a/strong").click() time.sleep(2) self.assertEqual("我的评论",driver.find_element_by_xpath("/html/body/div/div/div[2]/div[1]/div/div/div/span").text) managerView = driver.find_element_by_xpath("html/body/div/div/div[2]/div[2]/div/table/tbody/tr[1]/td/div[1]/span[1]") managerView.text self.assertEqual(u'经理评阅日志@%s'%nowtime,managerView.text) print u"员工可看到领导发布的评阅信息!" user.quit(self) driver.close()
def test_todaylog_11(self): '''发表评论''' driver = self.driver driver.get(self.base_url) #+ "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//*[@id='logComment']").send_keys( u"发表评论@%s" % time.ctime()) print u"发表评论内容为:发表评论@%s" % time.ctime() time.sleep(2) driver.find_element_by_xpath("//*[@id='btnComment']").click() time.sleep(3) user.quit(self)
def test_todaylog_15(self): '''查看本周计划''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'本周计划')]").click() driver.get_screenshot_as_file( "D:\\work\\mgt_webtest\\screenshot\\worklogtoweekplan%s" % time.strftime("%Y%m%d_%H%M%S", time.localtime())) time.sleep(2) driver.find_element_by_xpath("//div[@id='modal4weekplan']/div/button" ).click() #//button[@type='button'])[2] user.quit(self)
def test_project_add(self): '''新建项目''' driver = self.driver #driver.get(self.base_url)# + "/mgt/frame.jsp?url=MGT_PROJECT_MY") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) driver.find_element_by_id("realname").click() time.sleep(1) now = time.strftime('%Y%m%d_%H%M%S', time.localtime()) driver.find_element_by_id("targetName").send_keys(u"项目名称_%s" % now) time.sleep(1) f1 = driver.find_element_by_xpath( "//span/table/tbody/tr[2]/td/iframe" ) #/html/body/div[5]/div/div[2]/div/div/div[2]/table/tbody/tr[3]/td/div/span/table/tbody/tr[2]/td/iframe") driver.switch_to_frame(f1) driver.find_element_by_xpath("//*[@id='tinymce']").send_keys( u"项目描述@%s" % time.ctime()) driver.switch_to_default_content() pub.switchtoframe(self) time.sleep(1) driver.find_element_by_id("beginDateCheckBox").click() time.sleep(1) driver.find_element_by_id("endDateCheckBox").click() time.sleep(1) driver.find_element_by_xpath( "//a[@id='selectUserListBtnHref']").click() time.sleep(1) driver.find_element_by_xpath( "//input[@id='userListSelectSelfInput']").click() time.sleep(1) driver.find_element_by_xpath( "//input[@id='userListSubmitButton']").click() time.sleep(1) driver.find_element_by_xpath("//*[@id='submitAdd']").click() time.sleep(1) driver.find_element_by_id("confirmOk").click() print u"新建项目成功!项目名称_%s" % now time.sleep(2) user.quit(self)
def test_todaylog_07(self): '''上传附件''' driver = self.driver driver.get(self.base_url)# + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'上传附件')]").click() time.sleep(1) upatt = driver.find_element_by_id("attachForm").find_element_by_id("mgtfile") upatt.send_keys("D:\\work\\mgt_webtest\\data\\mailcontent.txt") print u"上传附件成功!" time.sleep(2) driver.find_element_by_id("myModal").find_element_by_id("btn_worklog_ok").click() time.sleep(2) user.quit(self)
def test_todaylog_12(self): '''修改评论''' driver = self.driver driver.get(self.base_url)#+ "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'编辑')]").click() time.sleep(3) driver.find_element_by_xpath("//*[@id='commentText']").clear() driver.find_element_by_xpath("//*[@id='commentText']").send_keys(u"编辑评论@%s"%time.ctime()) print u"评论内容修改为:编辑评论@%s"%time.ctime() time.sleep(2) driver.find_element_by_xpath("//*[@id='editCommentOk']").click() time.sleep(2) user.quit(self)
def test_planlist_01(self): '''新建日计划''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() time.sleep(3) pub.switchtoframe(self) driver.find_element_by_xpath("//li[2]/a/strong").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'新建日计划')]").click() time.sleep(2) driver.find_element_by_xpath("//*[@id='dayPlanContent']").send_keys(u"今日工作计划@%s"%time.ctime()) time.sleep(3) driver.find_element_by_xpath("//*[@id='btn_worklog_ok_dayPlan']").click() user.quit(self)
def test_todaylog_02(self): '''日计划状态修改''' driver = self.driver driver.get(self.base_url)# + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) planstatus = driver.find_element_by_xpath("//td/a/i") if planstatus.get_attribute('class') == 'mpic-deny': driver.find_element_by_css_selector('i.mpic-deny').click() print u"状态修改为已完成!" else: driver.find_element_by_css_selector('i.mpic-ok').click() print u"状态修改为未完成!" time.sleep(2) user.quit(self)
def test_mycomment_01(self): '''评论标签切换''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[4]/a/strong").click() time.sleep(2) self.assertEqual("我的评论",driver.find_element_by_xpath("/html/body/div/div/div[2]/div[1]/div/div/div/span").text) driver.find_element_by_xpath("//div[2]/div/div/ul/li[2]/a").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(@href, 'mycomment.do?type=received')]").click() print u"测试通过!" time.sleep(2) user.quit(self)
def test_todaylog_01(self): '''新建日计划''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[@id='newOrEditPendingMatter']").click() time.sleep(1) #使用二次定位的方法找到日计划对话框 dayplan = driver.find_element_by_id("myModalDayPlan").find_element_by_id("dayPlanContent") dayplan.send_keys(u"今日日计划_%s"%time.strftime("%Y_%m_%d-%H_%M_%S",time.localtime())) time.sleep(1) driver.find_element_by_id("btn_worklog_ok_dayPlan").click() time.sleep(1) print u"日计划创建成功!内容为:今日日计划_%s"%time.strftime("%Y_%m_%d-%H_%M_%S",time.localtime()) user.quit(self)
def test_todaylog_12(self): '''修改评论''' driver = self.driver driver.get(self.base_url) #+ "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'编辑')]").click() time.sleep(3) driver.find_element_by_xpath("//*[@id='commentText']").clear() driver.find_element_by_xpath("//*[@id='commentText']").send_keys( u"编辑评论@%s" % time.ctime()) print u"评论内容修改为:编辑评论@%s" % time.ctime() time.sleep(2) driver.find_element_by_xpath("//*[@id='editCommentOk']").click() time.sleep(2) user.quit(self)
def test_todaylog_02(self): '''日计划状态修改''' driver = self.driver driver.get( self.base_url) # + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) planstatus = driver.find_element_by_xpath("//td/a/i") if planstatus.get_attribute('class') == 'mpic-deny': driver.find_element_by_css_selector('i.mpic-deny').click() print u"状态修改为已完成!" else: driver.find_element_by_css_selector('i.mpic-ok').click() print u"状态修改为未完成!" time.sleep(2) user.quit(self)
def test_todaylog_10(self): '''删除附件''' driver = self.driver driver.get(self.base_url)# + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'删除')]").click() time.sleep(1) driver.find_element_by_xpath("//a[contains(text(),'取消')]").click()#取消删除 time.sleep(1) driver.find_element_by_xpath("//a[contains(text(),'删除')]").click() time.sleep(1) driver.find_element_by_xpath("//a[contains(text(),'确定')]").click()#确定删除 print u"删除成功!" time.sleep(2) user.quit(self)
def test_todaylog_04(self): '''新建工作记录''' driver = self.driver driver.get(self.base_url)# + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'新建工作记录')]").click() time.sleep(2) #使用二次定位的方法找到对话框中的文本框 worklog = driver.find_element_by_id("myModal").find_element_by_id("modalContent") worklog.send_keys(u"工作记录:%s"%time.strftime("%Y_%m_%d-%H_%M_%S",time.localtime())) time.sleep(1) driver.find_element_by_id("btn_worklog_ok").click() time.sleep(2) print u"工作记录:%s"%time.strftime("%Y_%m_%d-%H_%M_%S",time.localtime()) user.quit(self)
def test_project_status_1(self): '''完成项目''' driver = self.driver driver.get(self.base_url) # + "/mgt/frame.jsp?url=MGT_PROJECT_MY") user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) #筛选状态为进行中的项目,将第一个项目状态置为已完成 driver.find_element_by_id("statusFilter").click() time.sleep(0.5) filt = driver.find_element_by_id("mainStatusChange") time.sleep(1) filt.find_element_by_xpath("//option[@value='0']").click() time.sleep(1) driver.find_element_by_xpath("//td[3]/a").click() time.sleep(2) #点击完成按钮 driver.find_element_by_xpath("//div[4]/div/div[2]/span").click() time.sleep(2) okreason = driver.find_element_by_id("MgtPopup-Popup") okreason.find_element_by_id("reason").clear() okreason.find_element_by_id("reason").send_keys(u"项目已完成!") time.sleep(2) okreason.find_element_by_xpath("//input[@value='提交']").click() time.sleep(1) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id( "confirmOk").click() time.sleep(1) oktext = driver.find_element_by_id( "mgtAlertDivId").find_element_by_class_name("alertContentClass") oktext.text if oktext.text == u"修改成功": print u"项目已完成!" driver.find_element_by_id("mgtAlertDivId").find_element_by_id( "buttonOk").click() user.quit(self) else: print u"项目修改失败!!!" user.quit(self)
def test_mylog_01(self): '''查看评阅日志权限人''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(@href, 'mylog.do')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'看看谁有权评阅您的日志')]").click() time.sleep(2) pingyue = driver.find_element_by_xpath("/html/body/div[4]/div[2]/div") pingyue.text print u"有权评阅您的日志的有:%s"%pingyue.text driver.get_screenshot_as_file("D:\\work\\mgt_webtest\\screenshot\\permModalpeople%s"%time.strftime("%Y%m%d_%H%M%S",time.localtime())) time.sleep(2) driver.find_element_by_xpath("//div[@id='permModal']/div[3]/button").click()#find_element_by_xpath('//*[@id="permModal"]'). user.quit(self)
def test_planlist_01(self): '''新建日计划''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() time.sleep(3) pub.switchtoframe(self) driver.find_element_by_xpath("//li[2]/a/strong").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'新建日计划')]").click() time.sleep(2) driver.find_element_by_xpath("//*[@id='dayPlanContent']").send_keys( u"今日工作计划@%s" % time.ctime()) time.sleep(3) driver.find_element_by_xpath( "//*[@id='btn_worklog_ok_dayPlan']").click() user.quit(self)
def test_viewlog_03(self): '''删除评阅日志''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[5]/a/strong").click() time.sleep(2) self.assertEqual( "评阅日志", driver.find_element_by_xpath( "/html/body/div[1]/div/div[2]/div[1]/div/span").text) driver.find_element_by_xpath( "//div[@id='viewlogList']/table/tbody/tr/td/div").click() time.sleep(2) theFirstInfo = driver.find_element_by_xpath( "/html/body/div[1]/div/div[2]/div[4]/div/div/div[6]/div/table/tbody/tr[2]/td" ).text driver.find_element_by_xpath("//a[contains(text(),'删除')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'取消')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'删除')]").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'确定')]").click() time.sleep(2) #self.verifyEqual(theFirstInfo,driver.find_element_by_xpath("/html/body/div[1]/div/div[2]/div[4]/div/div/div[6]/div/table/tbody/tr[2]/td").text) if theFirstInfo != driver.find_element_by_xpath( "/html/body/div[1]/div/div[2]/div[4]/div/div/div[6]/div/table/tbody/tr[2]/td" ).text: print u"删除成功!" print u"删除的评论内容是:%s" % theFirstInfo else: print u"删除失败" user.quit(self)
def test_planlist_02(self): '''日计划状态''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() time.sleep(3) pub.switchtoframe(self) driver.find_element_by_xpath("//li[2]/a/strong").click() time.sleep(2) driver.find_element_by_css_selector("i.mpic-deny").click() time.sleep(2) print u"日计划状态已改为已完成!" driver.find_element_by_xpath("//a[2]/span").click() time.sleep(1) driver.find_element_by_css_selector("i.mpic-ok").click() time.sleep(1) print u"日计划状态恢复为未完成!" user.quit(self)
def test_todaylog_07(self): '''上传附件''' driver = self.driver driver.get( self.base_url) # + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'上传附件')]").click() time.sleep(1) upatt = driver.find_element_by_id("attachForm").find_element_by_id( "mgtfile") upatt.send_keys("D:\\work\\mgt_webtest\\data\\mailcontent.txt") print u"上传附件成功!" time.sleep(2) driver.find_element_by_id("myModal").find_element_by_id( "btn_worklog_ok").click() time.sleep(2) user.quit(self)
def test_planlist_02(self): '''日计划状态''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() time.sleep(3) pub.switchtoframe(self) driver.find_element_by_xpath("//li[2]/a/strong").click() time.sleep(2) driver.find_element_by_css_selector("i.mpic-deny").click() time.sleep(2) print u"日计划状态已改为已完成!" driver.find_element_by_xpath("//a[2]/span").click() time.sleep(1) driver.find_element_by_css_selector("i.mpic-ok").click() time.sleep(1) print u"日计划状态恢复为未完成!" user.quit(self)
def test_project_status_1(self): '''完成项目''' driver = self.driver driver.get(self.base_url)# + "/mgt/frame.jsp?url=MGT_PROJECT_MY") user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) #筛选状态为进行中的项目,将第一个项目状态置为已完成 driver.find_element_by_id("statusFilter").click() time.sleep(0.5) filt = driver.find_element_by_id("mainStatusChange") time.sleep(1) filt.find_element_by_xpath("//option[@value='0']").click() time.sleep(1) driver.find_element_by_xpath("//td[3]/a").click() time.sleep(2) #点击完成按钮 driver.find_element_by_xpath("//div[4]/div/div[2]/span").click() time.sleep(2) okreason = driver.find_element_by_id("MgtPopup-Popup") okreason.find_element_by_id("reason").clear() okreason.find_element_by_id("reason").send_keys(u"项目已完成!") time.sleep(2) okreason.find_element_by_xpath("//input[@value='提交']").click() time.sleep(1) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id("confirmOk").click() time.sleep(1) oktext = driver.find_element_by_id("mgtAlertDivId").find_element_by_class_name("alertContentClass") oktext.text if oktext.text == u"修改成功": print u"项目已完成!" driver.find_element_by_id("mgtAlertDivId").find_element_by_id("buttonOk").click() user.quit(self) else: print u"项目修改失败!!!" user.quit(self)
def test_todaylog_03(self): '''删除日计划''' driver = self.driver driver.get(self.base_url)# + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//td[3]/a/i").click() time.sleep(1) dayplan_del = driver.find_element_by_id("myModalDayPlan").find_element_by_id("btn_worklog_delete_dayPlan") dayplan_del.click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'取消')]").click()#取消删除 time.sleep(1) dayplan_del.click() time.sleep(1) driver.find_element_by_xpath("//a[contains(text(),'确定')]").click()#确认删除 time.sleep(2) print u"日计划删除成功!" user.quit(self)
def test_todaylog_14(self): '''创建昨日补充日志''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台",driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_css_selector("i.mpic-back").click() time.sleep(2) driver.find_element_by_xpath("//a[@id='supplementTip']").click() time.sleep(1) driver.find_element_by_xpath('//*[@id="modalContent"]').clear() driver.find_element_by_xpath('//*[@id="modalContent"]').send_keys(u"补充日志@%s"%time.ctime()) time.sleep(2) driver.find_element_by_xpath("//button[@id='btn_worklog_ok']").click() print u"补充昨日日志成功!" time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'今天')]").click() time.sleep(2) user.quit(self)
def test_todaylog_04(self): '''新建工作记录''' driver = self.driver driver.get( self.base_url) # + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'新建工作记录')]").click() time.sleep(2) #使用二次定位的方法找到对话框中的文本框 worklog = driver.find_element_by_id("myModal").find_element_by_id( "modalContent") worklog.send_keys(u"工作记录:%s" % time.strftime("%Y_%m_%d-%H_%M_%S", time.localtime())) time.sleep(1) driver.find_element_by_id("btn_worklog_ok").click() time.sleep(2) print u"工作记录:%s" % time.strftime("%Y_%m_%d-%H_%M_%S", time.localtime()) user.quit(self)
def test_todaylog_10(self): '''删除附件''' driver = self.driver driver.get( self.base_url) # + "/module/worklog/userfo.do?locale=zh_CN") user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//a[contains(text(),'删除')]").click() time.sleep(1) driver.find_element_by_xpath( "//a[contains(text(),'取消')]").click() #取消删除 time.sleep(1) driver.find_element_by_xpath("//a[contains(text(),'删除')]").click() time.sleep(1) driver.find_element_by_xpath( "//a[contains(text(),'确定')]").click() #确定删除 print u"删除成功!" time.sleep(2) user.quit(self)
def test_project_status_2(self): '''激活项目''' driver = self.driver driver.get(self.base_url) # + "/mgt/frame.jsp?url=MGT_PROJECT_MY") user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) #筛选状态为已完成的项目,撤销第一个项目 driver.find_element_by_id("statusFilter").click() time.sleep(0.5) filt = driver.find_element_by_id("mainStatusChange") time.sleep(1) filt.find_element_by_xpath("//option[@value='2']").click() time.sleep(1) driver.find_element_by_xpath("//td[3]/a").click() time.sleep(2) #点击激活按钮 driver.find_element_by_xpath("//div[2]/div/div[2]/span").click() time.sleep(2) actReason = driver.find_element_by_xpath("//*[@id='MgtPopup-Popup']") actReason.find_element_by_xpath("//*[@id='reason']").clear() driver.find_element_by_xpath("//*[@id='reason']").send_keys( u"激活理由@%s" % time.ctime()) print u"项目已激活成功!" time.sleep(2) actReason.find_element_by_xpath("//input[@value='提交']").click() time.sleep(1) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id( "confirmOk").click() time.sleep(2) driver.find_element_by_id("mgtAlertDivId").find_element_by_id( "buttonOk").click() time.sleep(1) print u"项目已激活!" user.quit(self)
def test_project_status_3(self): '''撤销项目''' driver = self.driver driver.get(self.base_url) # + "/mgt/frame.jsp?url=MGT_PROJECT_MY") user.login(self) time.sleep(2) pub.module_icon(self) driver.find_element_by_class_name("j_ico_project").click() pub.switchtoframe(self) #筛选状态为进行中的项目,撤销列表中的第一个项目 driver.find_element_by_id("statusFilter").click() time.sleep(0.5) filt = driver.find_element_by_id("mainStatusChange") time.sleep(1) filt.find_element_by_xpath("//option[@value='0']").click() time.sleep(1) pro_name = driver.find_element_by_xpath("//td[3]/a") #pro_name.text pro_name.click() time.sleep(2) #点击撤销按钮 driver.find_element_by_xpath("//div[3]/div/div[2]/span").click() time.sleep(2) cancelReason = driver.find_element_by_id("MgtPopup-Popup") cancelReason.find_element_by_id("reason").clear() cancelReason.find_element_by_id("reason").send_keys(u"项目需要撤销!") time.sleep(2) cancelReason.find_element_by_xpath("//input[@value='提交']").click() time.sleep(1) driver.find_element_by_id("mgtConfirmDivId").find_element_by_id( "confirmOk").click() time.sleep(2) driver.find_element_by_id("mgtAlertDivId").find_element_by_id( "buttonOk").click() time.sleep(1) print u"项目已撤销!" user.quit(self)
def test_viewlog_02(self): '''编辑评阅日志''' driver = self.driver driver.get(self.base_url) user.login(self) time.sleep(2) self.assertEqual("今目标企业工作平台", driver.title) pub.module_icon(self) driver.find_element_by_class_name("j_ico_log").click() pub.switchtoframe(self) driver.find_element_by_xpath("//li[5]/a/strong").click() time.sleep(2) self.assertEqual( "评阅日志", driver.find_element_by_xpath( "/html/body/div[1]/div/div[2]/div[1]/div/span").text) driver.find_element_by_xpath( "//div[@id='viewlogList']/table/tbody/tr/td/div").click() time.sleep(2) driver.find_element_by_xpath("//a[contains(text(),'编辑')]").click() time.sleep(2) nowtime = time.ctime() driver.find_element_by_xpath("//*[@id='commentText']").clear() driver.find_element_by_xpath("//*[@id='commentText']").send_keys( u"编辑经理评阅日志@%s" % nowtime) print u"编辑评阅日志成功!编辑后的评论内容:编辑经理评阅日志@%s" % nowtime time.sleep(2) driver.find_element_by_xpath("//*[@id='editCommentOk']").click() time.sleep(2) self.assertEqual( u"编辑经理评阅日志@%s" % nowtime, driver.find_element_by_xpath( "/html/body/div[1]/div/div[2]/div[4]/div/div/div[6]/div/table/tbody/tr[2]/td" ).text) user.quit(self) driver.close()