def login_automation_gmail_account(self, user_name, gmail_pwrd, xpected_uname): gmail_po = GmailLoginPageObjectsClass(self.driver) ca = CommonActionsClass(self.driver) common_utils = CommonUtilsClass() email_textbox_elmnt = gmail_po.email_text_box_loc() ca.enter_text_in_text_box(email_textbox_elmnt, user_name) logger.info("gmail Username:: " + user_name) time.sleep(3) next_btn_elmnt = gmail_po.next_button_loc() ca.click_on_webelement(next_btn_elmnt) time.sleep(3) pwrd_tbox_loc_elmnt = gmail_po.p_word_text_box_loc() pwrd_tbox_loc_elmnt.send_keys(Keys.TAB) time.sleep(3) gmail_password = common_utils.AES256_decrypt(master_key, gmail_pwrd) pwrd_tbox_loc_elmnt.send_keys(gmail_password) logger.info("Given gmail passcode") time.sleep(3) next_btn_elmnt = gmail_po.next_button_loc() ca.click_on_webelement(next_btn_elmnt) time.sleep(5) acct_elmnt = gmail_po.account_details_element() time.sleep(3) acct_elmnt.click() time.sleep(3) usr_name_elmnt = gmail_po.gmail_username_element() actul_usrname = usr_name_elmnt.text if actul_usrname == xpected_uname: logger.info("Logged in to the " + xpected_uname + " Gmail Account") return self.driver else: logger.error("Logged in to " + actul_usrname + " instead of " + xpected_uname + " mail Account") raise AssertionError()
def launch_googlechrome(self, web_url): comm = CommonUtilsClass() chrome_options = comm.build_chrome_options() webdriver_locn = webDriversfolder + "chromedriver.exe" self.driver = webdriver.Chrome(executable_path=webdriver_locn, chrome_options=chrome_options) self.driver.get(web_url) time.sleep(2) return self.driver
def save_attachment_content(self, target_filepath): commonutil = CommonUtilsClass() drvr = self.log_into_gmail(gmail_uname, gmail_pwrd, acct_username) gmllp = GmailLoginPageActionClass(drvr) date_time_stamp = commonutil.get_Value_In_IOparmetres("last_run_instance_time") string_to_search = commonutil.date_format_convert(date_time_stamp, 1, "360") drvr2 = gmllp.open_gmail_content(drvr, string_to_search) drvr3 = gmllp.open_mail_attachment(drvr2) drvr4 = gmllp.copy_attachment_content_to_textfile(drvr3, target_filepath) gmllp.gmail_sign_out(drvr4)
def restapi_put_status(self, testrunid_key, payload): comm_util = CommonUtilsClass() url = jiraendpoint_URL + '/testrun/' + str(testrunid_key) auth_string = comm_util.AES256_decrypt(master_key, jiraauth_cred) headers = { 'Content-Type': "application/json", 'Authorization': "Basic " + auth_string, 'Cache-Control': "no-cache", } response = requests.request("PUT", url, data=payload, headers=headers) return response.status_code
def restapi_get_testids(self, testexecution_key): comm_util = CommonUtilsClass() url = jiraendpoint_URL + '/testexec/' + testexecution_key + '/test' auth_string = comm_util.AES256_decrypt(master_key, jiraauth_cred) headers = { 'Content-Type': "application/json", 'Authorization': "Basic " + auth_string, 'Cache-Control': "no-cache", } response = requests.request("GET", url, headers=headers) return response.text
def open_mail_attachment(self, drvr): gmail_po = GmailLoginPageObjectsClass(drvr) commonutil = CommonUtilsClass() ca1 = CommonActionsClass(self.driver) timestamp = commonutil.last_user_created() time.sleep(5) mail_attachment_element = gmail_po.mail_attachment_loc(timestamp) ca1.hover_over_an_element_and_click(mail_attachment_element) logger.info( "Hovered and clicked on the mail attachment with name containing " + timestamp) time.sleep(2) return self.driver
def copy_attachment_content_to_textfile(self, drvr, target_filepath): gmail_po = GmailLoginPageObjectsClass(drvr) ca1 = CommonActionsClass(self.driver) commonutil = CommonUtilsClass() time_stamp = commonutil.last_user_created() attachment_message_element = gmail_po.mail_attachment_message_loc( time_stamp) attachment_message_data = attachment_message_element.text commonutil.write_data_into_file(target_filepath, attachment_message_data) mail_attachment_message_close_element = gmail_po.mail_attachment_message_close_loc( ) ca1.hover_over_an_element_and_click( mail_attachment_message_close_element) logger.info("Copied and pasted the error message in " + target_filepath + " file") return self.driver
def get_testrunids(self, testexecution_id): comm_util = CommonUtilsClass() jira_util = JiraUtilies() jiraapi_output = jira_util.restapi_get_testids(testexecution_id) return comm_util.read_jira_jsonfile(jiraapi_output)