def click_search(self): helper.save_screen_shot(self.driver, "click_search_before_search") # 不要去掉,否则不稳定 helper.wait_element(self.driver, *DebugLocator.webhook_search_Button) helper.wait_element_visible(self.driver, *DebugLocator.webhook_search_Button) search_webhook = self.driver.find_element(*DebugLocator.webhook_search_Button) helper.save_screen_shot(self.driver, "click_search_before_search") # 不要去掉,否则不稳定 search_webhook.click()
def filter_argu_handled(self): helper.wait_element(self.driver,*OrderLocator.filter_panel_Button) helper.wait_element_visible(self.driver,*OrderLocator.filter_panel_Button) filter_panel = self.driver.find_element(*OrderLocator.filter_panel_Button) filter_panel.click() helper.wait_element(self.driver,*OrderLocator.filter_pay_all) helper.wait_element_visible(self.driver,*OrderLocator.filter_pay_all) filter_paid = self.driver.find_element(*OrderLocator.filter_pay_all) filter_paid.click() helper.wait_element_visible(self.driver,*OrderLocator.filter_refund_all) filter_refunded = self.driver.find_element(*OrderLocator.filter_refund_all) filter_refunded.click() helper.wait_element(self.driver,*OrderLocator.filter_argu_handled) helper.wait_element_visible(self.driver,*OrderLocator.filter_argu_handled) filter_paid = self.driver.find_element(*OrderLocator.filter_argu_handled) filter_paid.click() helper.save_screen_shot(self.driver,"filter_argu_handled_for_redenvelope") helper.wait_element_visible(self.driver,*OrderLocator.filter_apply_Button) filter_apply = self.driver.find_element(*OrderLocator.filter_apply_Button) filter_apply.click()
def Get_result(self): helper.save_screen_shot(self.driver, "Get_result") helper.wait_element_visible(self.driver, *DebugLocator.webhook_event) helper.wait_element(self.driver, *DebugLocator.webhook_result) helper.wait_element_visible(self.driver, *DebugLocator.webhook_result) result = self.driver.find_element(*DebugLocator.webhook_result) return result.text
def click_refund_Button(self): helper.save_screen_shot(self.driver,"click_refund_Button_before") helper.wait_element(self.driver, *OrderLocator.refund_Button) helper.wait_element_visible(self.driver, *OrderLocator.refund_Button) refund_button = self.driver.find_element(*OrderLocator.refund_Button) refund_button.click() time.sleep(1)
def click_next_step(self): helper.wait_element_visible( self.driver, *OrderLocator.next_step_Button) next_step_button = self.driver.find_element( *OrderLocator.next_step_Button) next_step_button.click() helper.save_screen_shot(self.driver,"batch_refund_click_next_step")
def close_detail(self): helper.save_screen_shot(self.driver,"close_detail") helper.wait_element(self.driver,*OrderLocator.close_detail_Button) helper.wait_element_visible(self.driver,*OrderLocator.close_detail_Button) detail_button = self.driver.find_element( *OrderLocator.close_detail_Button) detail_button.click() helper.wait_element_invisible(self.driver,*OrderLocator.close_detail_Button)
def click_register_button(self): helper.wait_element_visible(self.driver,*LogInOutLocators.register_email_Button) send_email = self.driver.find_element( *LogInOutLocators.register_email_Button) send_email.click() helper.wait_element_visible(self.driver, *LogInOutLocators.registered_email_Link) helper.save_screen_shot(self.driver,"click_register_button_email_link")
def upload_batchPay_csv(self): helper.wait_element(self.driver,*OrderLocator.batch_pay_upload_Input) file_input = self.driver.find_element(*OrderLocator.batch_pay_upload_Input) self.driver.execute_script("document.getElementById('batch_pay_file').style.display = 'inherit';") helper.save_screen_shot(self.driver,"upload_template") path = helper.current_path()+"/batchPay_w.csv" file_input.send_keys(path) # self.driver.executePhantomJS("var page = this; page.uploadFile('input[type=file]', path);") time.sleep(2)
def click_batchPay_tab(self): helper.save_screen_shot(self.driver,"click_batch_transfer") helper.wait_element( self.driver, *OrderLocator.batch_transfer_tab) helper.wait_element_visible( self.driver, *OrderLocator.batch_transfer_tab) batch_opeation = self.driver.find_element( *OrderLocator.batch_transfer_tab) batch_opeation.click()
def input_refund_amount(self): # input refund comment helper.save_screen_shot(self.driver,"input_refund_amount_before") helper.wait_element( self.driver, *OrderLocator.refund_amount) helper.wait_element_visible( self.driver, *OrderLocator.refund_amount) amount = self.driver.find_element(*OrderLocator.refund_amount) amount.click() amount.clear() amount.send_keys("0.05")
def verify_no_order(self): helper.wait_element_visible(self.driver, *OrderLocator.order_table) order_table = self.driver.find_element(*OrderLocator.order_table) while order_table.text.find(u'加载更多') >= 0: print "still waiting" time.sleep(1) order_table = self.driver.find_element( *OrderLocator.order_table) helper.save_screen_shot(self.driver,"verify_no_order") print order_table.text assert order_table.text == u'暂无订单'
def verify_no_handel_argument(self): helper.wait_element(self.driver,*OrderLocator.argu_Button) helper.wait_element_visible(self.driver,*OrderLocator.argu_Button) argu_detail = self.driver.find_element(*OrderLocator.argu_Button) argu_detail.text.find(u'争议已提交') helper.wait_element(self.driver,*OrderLocator.argu_reason) helper.wait_element_visible(self.driver,*OrderLocator.argu_reason) helper.save_screen_shot(self.driver,"verify_no_handel_argument") argu_reason = self.driver.find_element(*OrderLocator.argu_reason) assert len(argu_reason.text)>=5
def select_alipay_pc_channel(self): helper.wait_element_visible(self.driver,*OrderLocator.channel_Select) channel_select = self.driver.find_element(*OrderLocator.channel_Select) channel_select.click() time.sleep(2) helper.wait_element(self.driver,*OrderLocator.channel_alipay_pc) helper.wait_element_visible(self.driver,*OrderLocator.channel_alipay_pc) alipay_pc = self.driver.find_element( *OrderLocator.channel_alipay_pc) alipay_pc.click() helper.save_screen_shot(self.driver,"select_alipay_pc_channel")
def add_webhook(self,wh_url): helper.wait_element(self.driver, *WebHookLocator.add_Button) helper.wait_element_visible(self.driver, *WebHookLocator.add_Button) add = self.driver.find_element(*WebHookLocator.add_Button) add.click() helper.save_screen_shot(self.driver,"add_webhook_before_input") self.input_url_invalid(wh_url) self.choose_live_mode() self.choose_all_event() self.save_webhook() #after added an url, should refresh the page to reload DOM. self.driver.refresh()
def upload_template(self): # helper.wait_element_visible(self.driver,*OrderLocator.batch_upload_link) # upload = self.driver.find_element(*OrderLocator.batch_upload_link) #upload.click() helper.wait_element(self.driver,*OrderLocator.batch_upload_input) file_input = self.driver.find_element(*OrderLocator.batch_upload_input) self.driver.execute_script("document.getElementById('upload_test_csv').style.display = 'inherit';") helper.save_screen_shot(self.driver,"upload_template") path = helper.current_path()+"/chargeid.csv" file_input.send_keys(path) #self.driver.executePhantomJS("var page = this; page.uploadFile('input[type=file]', path);") time.sleep(2)
def click_batch_refund(self): helper.save_screen_shot(self.driver,"click_batch_refund") helper.wait_element( self.driver, *OrderLocator.batch_opeation_Dropdown) helper.wait_element_visible( self.driver, *OrderLocator.batch_opeation_Dropdown) batch_opeation = self.driver.find_element(*OrderLocator.batch_opeation_Dropdown) batch_opeation.click() helper.wait_element(self.driver, *OrderLocator.batch_refund_Option) helper.wait_element_visible(self.driver, *OrderLocator.batch_refund_Option) batch_refund = self.driver.find_element(*OrderLocator.batch_refund_Option) batch_refund.click()
def refund_by_link(self): helper.wait_element_visible(self.driver, *OrderLocator.m_refund_remark) remark = self.driver.find_element(*OrderLocator.m_refund_remark) remark.send_keys("test refund via link by automation") refund_link = self.driver.find_element( *OrderLocator.confirm_refund_Button) refund_link.click() helper.wait_element(self.driver, *OrderLocator.goto_refund_link) helper.save_screen_shot(self.driver,"refund_by_link") refund_link = self.driver.find_element(*OrderLocator.goto_refund_link) close_refund_link = self.driver.find_element(*OrderLocator.close_refund_link_popup) helper.save_screen_shot(self.driver,"refund_by_link") close_refund_link.click()
def click_register_alert(self): helper.wait_element(self.driver,*LogInOutLocators.register_email_Button) helper.wait_element_visible(self.driver,*LogInOutLocators.register_email_Button) send_email = self.driver.find_element( *LogInOutLocators.register_email_Button) send_email.click() helper.save_screen_shot(self.driver,"click_register_alert_popup") helper.wait_element( self.driver, *LogInOutLocators.register_alert_pop) helper.wait_element_visible( self.driver, *LogInOutLocators.register_alert_pop) alert = self.driver.find_element(*LogInOutLocators.register_alert_pop) helper.save_screen_shot(self.driver,"click_register_alert_ok") return alert
def filter_argu_nohandle(self): helper.wait_element(self.driver,*OrderLocator.filter_panel_Button) helper.wait_element_visible(self.driver,*OrderLocator.filter_panel_Button) filter_panel = self.driver.find_element(*OrderLocator.filter_panel_Button) filter_panel.click() helper.wait_element(self.driver,*OrderLocator.filter_argu_no_handle) helper.wait_element_visible(self.driver,*OrderLocator.filter_argu_no_handle) filter_nohandle = self.driver.find_element(*OrderLocator.filter_argu_no_handle) filter_nohandle.click() helper.wait_element_visible(self.driver,*OrderLocator.filter_apply_Button) filter_apply = self.driver.find_element(*OrderLocator.filter_apply_Button) filter_apply.click() helper.save_screen_shot(self.driver,"filter_argu_nohandle_apply_after")
def test_day(self,wh_url): helper.wait_element(self.driver,*WebHookLocator.wh_test_selEvent) helper.wait_element_visible(self.driver,*WebHookLocator.wh_test_selEvent) select_event = self.driver.find_element(*WebHookLocator.wh_test_selEvent) select_event.click() helper.wait_element(self.driver,*WebHookLocator.wh_test_sumDay) helper.wait_element_visible(self.driver,*WebHookLocator.wh_test_sumDay) test_refund = self.driver.find_element(*WebHookLocator.wh_test_sumDay) test_refund.click() helper.wait_element(self.driver,*WebHookLocator.wh_launch_test) helper.wait_element_visible(self.driver,*WebHookLocator.wh_launch_test) launch_test = self.driver.find_element(*WebHookLocator.wh_launch_test) launch_test.click() helper.save_screen_shot(self.driver,"test_daysum_result") helper.wait_element(self.driver,*WebHookLocator.wh_Test_reponse) helper.wait_element_visible(self.driver,*WebHookLocator.wh_Test_reponse) self.verify_response(wh_url)
def delete_webhook(self,wh_url): helper.save_screen_shot(self.driver,"delete_webhook_before") helper.wait_element( self.driver, *WebHookLocator.webHookList_List) helper.wait_element_visible( self.driver, *WebHookLocator.webHookList_List) wh_rows = self.driver.find_elements(*WebHookLocator.webHookList_Rows) for row in wh_rows: if row.text.find(wh_url) >= 0: helper.wait_element(self.driver,*WebHookLocator.delete_wb_Icon) helper.wait_element_visible(self.driver,*WebHookLocator.delete_wb_Icon) delete=row.find_element_by_class_name("icon-delete") delete.click() helper.wait_element(self.driver,*WebHookLocator.confirm_ok_Button) helper.wait_element_visible(self.driver,*WebHookLocator.confirm_ok_Button) confirm = self.driver.find_element(*WebHookLocator.confirm_ok_Button) confirm.click() helper.save_screen_shot(self.driver,"delete_webhook_after")
def test_enve_received(self,wh_url): helper.wait_element(self.driver,*WebHookLocator.wh_test_selEvent) helper.wait_element_visible(self.driver,*WebHookLocator.wh_test_selEvent) select_event = self.driver.find_element(*WebHookLocator.wh_test_selEvent) select_event.click() helper.save_screen_shot(self.driver,"wh_test_enve_received_before") helper.wait_element(self.driver,*WebHookLocator.wh_test_enve_received) helper.wait_element_visible(self.driver,*WebHookLocator.wh_test_enve_received) test_refund = self.driver.find_element(*WebHookLocator.wh_test_enve_received) test_refund.click() helper.save_screen_shot(self.driver,"wh_test_enve_received_after") helper.wait_element(self.driver,*WebHookLocator.wh_launch_test) helper.wait_element_visible(self.driver,*WebHookLocator.wh_launch_test) launch_test = self.driver.find_element(*WebHookLocator.wh_launch_test) launch_test.click() helper.wait_element(self.driver,*WebHookLocator.wh_Test_reponse) helper.wait_element_visible(self.driver,*WebHookLocator.wh_Test_reponse) self.verify_response(wh_url)
def detail_paid_refunded(self): helper.wait_element_visible(self.driver, *OrderLocator.detail_frame) helper.save_screen_shot(self.driver,"detail_paid_refunded") helper.wait_element(self.driver,*OrderLocator.refund_history) helper.wait_element_visible(self.driver,*OrderLocator.refund_history) detail_refund_history = self.driver.find_element( *OrderLocator.refund_history).text while detail_refund_history.find(u'加载中') >= 0: print "still waiting" helper.wait_seconds(1) detail_refund_history = self.driver.find_element( *OrderLocator.refund_history).text helper.wait_element_visible(self.driver,*OrderLocator.detail_actual_amount) detail_actual_amount = self.driver.find_element( *OrderLocator.detail_actual_amount) detail_refunded = self.driver.find_element( *OrderLocator.detail_refunded_amount) return detail_actual_amount.text, detail_refunded.text, detail_refund_history
def filter_no_pay(self): helper.wait_element(self.driver,*OrderLocator.filter_panel_Button) helper.wait_element_visible(self.driver,*OrderLocator.filter_panel_Button) filter_panel = self.driver.find_element(*OrderLocator.filter_panel_Button) filter_panel.click() helper.wait_element_visible(self.driver,*OrderLocator.filter_nopay) filter_nopay = self.driver.find_element(*OrderLocator.filter_nopay) filter_nopay.click() helper.save_screen_shot(self.driver,"filter_nopay_refunded_nopay") helper.wait_element_visible(self.driver,*OrderLocator.filter_refund_all) filter_refund_all = self.driver.find_element(*OrderLocator.filter_refund_all) filter_refund_all.click() helper.wait_element_visible(self.driver,*OrderLocator.filter_argu_all) filter_argu_all = self.driver.find_element(*OrderLocator.filter_argu_all) filter_argu_all.click() helper.wait_element_visible(self.driver,*OrderLocator.filter_apply_Button) filter_apply = self.driver.find_element(*OrderLocator.filter_apply_Button) filter_apply.click() helper.save_screen_shot(self.driver,"filter_nopay_refunded_applied")
def test_webhook_url(self,wh_url): helper.save_screen_shot(self.driver,"test_webhook_url") helper.wait_element( self.driver, *WebHookLocator.webHookList_Rows) helper.wait_element_visible( self.driver, *WebHookLocator.webHookList_Rows) wh_rows = self.driver.find_elements(*WebHookLocator.webHookList_Rows) for row in wh_rows: if row.text.find(wh_url) >= 0: helper.wait_element(self.driver, *WebHookLocator.test_wb_Icon) helper.wait_element_visible(self.driver, *WebHookLocator.test_wb_Icon) test = row.find_element_by_class_name("icon-test") test.click() print time.strftime("%Y%m%d%H%M%S") self.test_day(wh_url) self.test_week(wh_url) self.test_month(wh_url) self.test_charge(wh_url) self.test_refund(wh_url) self.test_enve_received(wh_url) self.test_enve_sent(wh_url) self.test_transfer(wh_url) print time.strftime("%Y%m%d%H%M%S")
def input_url_invalid(self,webhook_url): helper.save_screen_shot(self.driver,"input_url_http_select_before") helper.wait_element(self.driver, *WebHookLocator.http_select) helper.wait_element_visible(self.driver, *WebHookLocator.http_select) wb_http_select = self.driver.find_element(*WebHookLocator.http_select) wb_http_select.click() helper.save_screen_shot(self.driver,"input_url_http_option_before") helper.wait_element_visible(self.driver, *WebHookLocator.http_Option) https_option = self.driver.find_element(*WebHookLocator.http_Option) https_option.click() helper.save_screen_shot(self.driver,"input_url_http_option_after") wb_http_url = self.driver.find_element(*WebHookLocator.wb_url_Input) wb_http_url.clear() wb_http_url.send_keys(webhook_url)
def click_batch_link(self): helper.wait_element_visible(self.driver,*OrderLocator.refund_by_link_alipay) alipay_link = self.driver.find_element(*OrderLocator.refund_by_link_alipay) alipay_link.click() try: helper.wait_element_visible(self.driver,*OrderLocator.pop_box) batch_refund_link = self.driver.find_element(*OrderLocator.goto_refund_link) except Exception,e: logging.error(e) helper.save_screen_shot(self.driver,"click_batch_link") alert_popup= self.driver.find_element(*OrderLocator.refund_alert_btn) alert_popup.click() helper.save_screen_shot(self.driver,"click_batch_link_again_before") # 此处生成退款url需要等待一段时间 time.sleep(5) helper.wait_element_visible(self.driver,*OrderLocator.refund_by_link_alipay) alipay_link = self.driver.find_element(*OrderLocator.refund_by_link_alipay) alipay_link.click() helper.save_screen_shot(self.driver,"click_batch_link_again_after")
def verify_refund100_status(self): helper.save_screen_shot(self.driver,"before_verify_refund100_status") helper.wait_element( self.driver, *OrderLocator.batch_opeation_Dropdown) helper.wait_element_visible( self.driver, *OrderLocator.batch_opeation_Dropdown) batch_opeation = self.driver.find_element( *OrderLocator.batch_opeation_Dropdown) batch_opeation.click() helper.wait_element(self.driver, *OrderLocator.batch_refund_Option) helper.wait_element_visible(self.driver, *OrderLocator.batch_refund_Option) batch_refund = self.driver.find_element(*OrderLocator.batch_refund_Option) batch_refund.click() # wait seconds, for refund status not update so quickly. helper.wait_seconds(2) helper.wait_element(self.driver,*OrderLocator.view_history_tab) helper.wait_element_visible(self.driver,*OrderLocator.view_history_tab) history_tab= self.driver.find_element(*OrderLocator.view_history_tab) history_tab.click() # verify batch refund number helper.save_screen_shot(self.driver,"verify_refund_status_goto_history") helper.wait_element(self.driver,*OrderLocator.refund_history_count) helper.wait_element_visible(self.driver,*OrderLocator.refund_history_count) batch_history_count = self.driver.find_element(*OrderLocator.refund_history_count) logging.info("batch refund count: "+batch_history_count.text) print batch_history_count.text assert batch_history_count.text == '100' # verify batch refund amount helper.wait_element_visible(self.driver,*OrderLocator.refund_history_amount) batch_history_amount = self.driver.find_element(*OrderLocator.refund_history_amount) logging.info("batch refund amount: "+ batch_history_amount.text) print batch_history_amount assert batch_history_amount.text == '9.95' helper.save_screen_shot(self.driver,"verify_refund_status_history")
def verify_result(self): helper.save_screen_shot(self.driver, "verify_result") helper.wait_element(self.driver, *DebugLocator.webhook_table) helper.wait_element_visible(self.driver, *DebugLocator.webhook_table) webhook_recend = self.driver.find_element(*DebugLocator.webhook_resend) assert webhook_recend.text == u"点此重发"
def edit_webhook(self): helper.save_screen_shot(self.driver,"edit_webhook") helper.wait_element( self.driver, *WebHookLocator.webHookList_List) helper.wait_element_visible( self.driver, *WebHookLocator.webHookList_List) wh_rows = self.driver.find_elements(*WebHookLocator.webHookList_Rows) wh_url = datagen.get_webhook_url_invalid() for row in wh_rows: if row.text.find(wh_url) >= 0: helper.wait_element(self.driver,*WebHookLocator.edit_wb_Icon) helper.wait_element_visible(self.driver,*WebHookLocator.edit_wb_Icon) edit = row.find_element_by_class_name("icon-edit") edit.click() helper.save_screen_shot(self.driver,"edit_webhook_editing") time.sleep(1) selectBtn = row.find_elements_by_class_name("selectBtn") for select in selectBtn: select.click() helper.save_screen_shot(self.driver,"edit_webhook_editing2") time.sleep(1) selectoptions = row.find_elements_by_class_name("virtualCheckbox") for option in selectoptions: option.click() helper.save_screen_shot(self.driver,"edit_webhook_editing3") time.sleep(1) save = row.find_element_by_class_name("btnDashboard") save.click() helper.save_screen_shot(self.driver,"edit_webhook_editing4") helper.wait_element_visible(self.driver,*WebHookLocator.webhook_event_alert) warning = self.driver.find_element(*WebHookLocator.webhook_event_alert) warning.click() helper.save_screen_shot(self.driver,"edit_webhook_alert") time.sleep(1) selectBtn = row.find_elements_by_class_name("selectBtn") for select in selectBtn: select.click() time.sleep(1) selectoptions = row.find_elements_by_class_name("virtualCheckbox") for option in selectoptions: option.click() continue time.sleep(1) helper.save_screen_shot(self.driver,"edit_webhook_before_save") save = row.find_element_by_class_name("btnDashboard") save.click() helper.save_screen_shot(self.driver,"edit_webhook_after_save") time.sleep(1)