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 filter_paid_refunded(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_paid) helper.wait_element_visible(self.driver,*OrderLocator.filter_paid) filter_paid = self.driver.find_element(*OrderLocator.filter_paid) filter_paid.click() helper.wait_element_visible(self.driver,*OrderLocator.filtet_refunded) filter_refunded = self.driver.find_element(*OrderLocator.filtet_refunded) filter_refunded.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.save_screen_shot(self.driver,"filter_paid_refunded") 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_paid_refunded_applied")
def fill_alipay_params(self): helper.wait_element(self.driver, *ChannelLocator.alipay_pid) pid = self.driver.find_element(*ChannelLocator.alipay_pid) alipay_pid = Data.channel_param.ALIPAY_CHANNEL_PARAM.get("alipay_pid") pid.send_keys(alipay_pid) account = self.driver.find_element(*ChannelLocator.alipay_account) alipay_account = Data.channel_param.ALIPAY_CHANNEL_PARAM.get( "alipay_account") account.send_keys(alipay_account) security_key = self.driver.find_element( *ChannelLocator.alipay_security_key) alipay_security_key = Data.channel_param.ALIPAY_CHANNEL_PARAM.get( "alipay_security_key") security_key.send_keys(alipay_security_key) public_key = self.driver.find_element( *ChannelLocator.alipay_app_public_key) alipay_public_key = Data.channel_param.ALIPAY_CHANNEL_PARAM.get( "alipay_public_key") public_key.send_keys(alipay_public_key) private_key = self.driver.find_element( *ChannelLocator.alipay_app_private_key) alipay_private_key = Data.channel_param.ALIPAY_CHANNEL_PARAM.get( "alipay_private_key") private_key.send_keys(alipay_private_key) submit_button = self.driver.find_element( *ChannelLocator.alipay_save_Button) submit_button.click()
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 get_red_id(self): helper.wait_element( self.driver, *OrderLocator.redId_first_row) helper.wait_element_visible( self.driver, *OrderLocator.redId_first_row) redId = self.driver.find_element(*OrderLocator.redId_first_row) return redId
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 create_batchPay(self): helper.wait_element( self.driver, *OrderLocator.create_batchpay_Button) helper.wait_element_visible( self.driver, *OrderLocator.create_batchpay_Button) batch_opeation = self.driver.find_element( *OrderLocator.create_batchpay_Button) batch_opeation.click()
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_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 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 select_charge_type(self): helper.wait_element_visible(self.driver,*OrderLocator.order_type_Select) order_type_select = self.driver.find_element( *OrderLocator.order_type_Select) order_type_select.click() helper.wait_element( self.driver, *OrderLocator.order_type_charge) order_charge = self.driver.find_element( *OrderLocator.order_type_charge) order_charge.click()
def get_channel(self): helper.wait_element( self.driver, *OrderLocator.channel_first_row) helper.wait_element_visible( self.driver, *OrderLocator.channel_first_row) try: channel = self.driver.find_element(*OrderLocator.channel_first_row) logging.info(channel.text) except Exception,e: logging.error(Exception,e)
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)
def select_upacp_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(1) helper.wait_element(self.driver,*OrderLocator.channel_upacp) helper.wait_element_visible(self.driver,*OrderLocator.channel_upacp) upacp = self.driver.find_element( *OrderLocator.channel_upacp) upacp.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 select_jdpay_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(1) helper.wait_element(self.driver,*OrderLocator.channel_jdpay) helper.wait_element_visible(self.driver,*OrderLocator.channel_jdpay) jdpay = self.driver.find_element( *OrderLocator.channel_jdpay) jdpay.click()
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 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 verify_handled_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_visible(self.driver,*OrderLocator.argu_reason) argu_reason = self.driver.find_element(*OrderLocator.argu_reason) assert len(argu_reason.text)>=5 helper.wait_element_visible(self.driver,*OrderLocator.argu_result) argu_reason = self.driver.find_element(*OrderLocator.argu_result) assert len(argu_reason.text)>= 0
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 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 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_app(self,account): helper.wait_element(self.driver,*HomePageLocator.apps) app_names = self.driver.find_elements(*HomePageLocator.apps) if account == "common": app_id = datagen.get_current_app1() elif account == "my": app_id = datagen.get_my_app() elif account == "contest": app_id = datagen.get_my_app2() else: app_id = datagen.get_other_app() for app_name in app_names: if app_name.get_attribute("app_id") == app_id: app_name.click() break
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 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 select_alipay_qr_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(1) current_env = datagen.get_env_name() if current_env == "Pinpula": helper.wait_element(self.driver,*OrderLocator.channel_alipay_qr) helper.wait_element_visible(self.driver,*OrderLocator.channel_alipay_qr) alipay_qr = self.driver.find_element( *OrderLocator.channel_alipay_qr) alipay_qr.click() else: helper.wait_element(self.driver,*OrderLocator.channel_alipay_qr_cil) helper.wait_element_visible(self.driver,*OrderLocator.channel_alipay_qr_cil) alipay_qr = self.driver.find_element( *OrderLocator.channel_alipay_qr_cil) alipay_qr.click()
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 input_password_confirm(self, is_private = False): try: helper.wait_element(self.driver,*OrderLocator.pop_box_message) helper.wait_element_visible(self.driver,*OrderLocator.pop_box_message) message = self.driver.find_element(*OrderLocator.pop_box_message) if message.text.find(u'登录密码')>=0: helper.wait_element_visible( self.driver, *OrderLocator.refund_confirm_pass) pwd = self.driver.find_element(*OrderLocator.refund_confirm_pass) if is_private == False: current_password = datagen.get_current_pwd() elif is_private == True: current_password = datagen.get_anti_pwd() pwd.send_keys(current_password) helper.wait_element_visible( self.driver, *OrderLocator.post_pass_Button) postpwd = self.driver.find_element(*OrderLocator.post_pass_Button) postpwd.click() time.sleep(2) except Exception,e: pass