How to use my_unlock method in autotest

Best Python code snippet using autotest_python

auto_updaterefnum.py

Source: auto_updaterefnum.py Github

copy

Full Screen

1#!/usr/bin/python2# FINAL SCRIPT updated as of 8th July 20203# Workflow - MSIG4# Declare Python libraries needed for this script5import sys6import pandas as pd7import time8import os9import wx10from utils.notification import send11from automagica import *12from connector.dbconfig import read_db_config13from selenium import webdriver14from pathlib import Path15from utils.audit_trail import audit_log16from utils.logging import logging17from selenium.webdriver.common.action_chains import ActionChains18from selenium.webdriver.common.keys import Keys19current_path = os.path.dirname(os.path.abspath(__file__))20dti_path = str(Path(current_path).parent)21# Function to open a web browser22def initBrowser(main_df, msig_base):23 global browser24 try:25 #msig_base.username = ''26 #msig_base.password = ''27 # Check if both username and password are not null28 if msig_base.username != '' and msig_base.password != '':29 # Open using FireFox30 browser = webdriver.Firefox(executable_path = dti_path+r'/selenium_interface/geckodriver.exe')31 browser.maximize_window()32 #browser.get('https://marcmy.asia-assistance.com/marcmy/')33 browser.get('http://marcmyuat.aan.com:8080/marcmy/')34 browser.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form/input[2]').clear()35 Wait(3)36 browser.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form/input[2]').send_keys(msig_base.username)37 Wait(2)38 browser.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form/input[3]').clear()39 Wait(3)40 browser.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form/input[3]').send_keys(msig_base.password)41 Wait(2)42 browser.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form/button').click()43 Wait(3)44 else:45 config = read_db_config(dti_path+r'\config.ini', 'marc-finance')46 dti_user = config['user']47 dti_pass = config['password']48 # Open using FireFox49 browser = webdriver.Firefox(executable_path = dti_path+r'/selenium_interface/geckodriver.exe')50 browser.maximize_window()51 #browser.get('https://marcmy.asia-assistance.com/marcmy/')52 browser.get('http://marcmyuat.aan.com:8080/marcmy/')53 browser.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form/input[2]').clear()54 Wait(3)55 browser.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form/input[2]').send_keys(dti_user)56 Wait(2)57 browser.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form/input[3]').clear()58 Wait(3)59 browser.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form/input[3]').send_keys(dti_pass)60 Wait(2)61 browser.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/form/button').click()62 Wait(3)63 checkresultdf = msig_dataRetrieve(main_df, msig_base)64 close_Marc(browser)65 return checkresultdf66 except Exception as error:67 close_Marc(browser)68 logging("MSIG - initBrowser", error, msig_base)69 print(error)70# Update Reference Number in MARC71def msig_dataRetrieve(main_df, msig_base):72 admNoList = main_df['Adm. No']73 clientRefNumList = main_df['Client Ref.Num']74 refnum_updated = list()75 refnum_notupdated = list()76 i = 077 for i in range(len(admNoList)):78 try:79 msig_marc(int(admNoList[i]), str(clientRefNumList[i]), msig_base)80 time.sleep(5)81 except Exception:82 audit_log("MSIG - Admission No %s can't be processed. Please check manually" %int(admNoList[i]), "Completed...", msig_base)83 continue84 for i in range(len(admNoList)):85 try:86 refnum_checkdf = refnum_check(int(admNoList[i]), msig_base,refnum_updated,refnum_notupdated)87 time.sleep(5)88 except Exception as error:89 audit_log("MSIG - Reference number checking", error, msig_base)90 continue91 return refnum_checkdf92# Menuevering dataset based on Case ID and update the record93def msig_marc(admNoList, clientRefNumList, msig_base):94 # Direct to Inpatient Cases search page95 #browser.get('https://marcmy.asia-assistance.com/marcmy/pages/inpatient/cases/inpatient_cases_search.xhtml')96 browser.get('http://marcmyuat.aan.com:8080/marcmy/pages/inpatient/cases/inpatient_cases_search.xhtml')97 Wait(5)98 # Find client's information using Admission ID99 browser.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[2]/table[1]/tbody/tr[1]/td[4]/input').send_keys(admNoList)100 Wait(5)101 browser.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[2]/table[1]/tbody/tr[11]/td[2]/button[1]').click()102 Wait(5)103 # Click client's name (a link)104 browser.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[2]/div/div/div/div[3]/table/tbody/tr/td[4]/a').click()105 Wait(5)106 # Click update button107 browser.find_element_by_xpath('/html/body/div[1]/div[3]/form[1]/div[1]/div[1]/div[1]/a[5]').click()108 Wait(5)109 # Clear the textarea and paste new reference number110 try:111 element_textare = '/html/body/div[1]/div[3]/form[1]/div[3]/div[2]/div/div/div[1]/table/tbody/tr[1]/td[2]/input'112 textare = browser.find_element_by_xpath(element_textare)113 textare.clear()114 ActionChains(browser).move_to_element(textare).click(textare).send_keys(clientRefNumList).perform()115 except Exception:116 try:117 time.sleep(3)118 element_textare = '/html/body/div[1]/div[3]/form[1]/div[3]/div[2]/div/div/div[1]/table/tbody/tr[1]/td[2]/input'119 textare = browser.find_element_by_xpath(element_textare)120 textare.click()121 textare.clear()122 textare.send_keys(clientRefNumList)123 except Exception as error:124 logging("MSIG - Automagica - Clear the textarea and paste new reference number", error, msig_base)125 pass126 Wait(5)127 # Save the record128 browser.find_element_by_xpath('/html/body/div[1]/div[3]/form[1]/div[1]/div[1]/div[1]/a[5]').click()129 Wait(5)130 # Unlock the Case ID131 try:132 ActionChains(browser).send_keys(Keys.RIGHT).perform()133 element_unlock = '/html/body/div[1]/div[3]/form[1]/div[1]/div[1]/div[2]/span[5]'134 my_unlock = browser.find_element_by_xpath(element_unlock)135 my_unlock.click()136 Wait(5)137 audit_log("MSIG - Case ID [ %s ] has been unlocked." % admNoList, "Completed...", msig_base)138 except Exception:139 try:140 ActionChains(browser).send_keys(Keys.RIGHT).perform()141 element_unlock = '/html/body/div[1]/div[3]/form[1]/div[1]/div[1]/div[2]/a[3]/img'142 my_unlock = browser.find_element_by_xpath(element_unlock)143 my_unlock.click()144 audit_log("MSIG - Case ID [ %s ] has been unlocked." % admNoList, "Completed...", msig_base)145 except Exception as error:146 logging("MSIG - Automagica - Unlock the Case ID properly", error, msig_base)147 pass148 Wait(5)149def refnum_check(admNoList, msig_base,refnum_updated,refnum_notupdated):150 #browser.get('https://marcmy.asia-assistance.com/marcmy/pages/inpatient/cases/inpatient_cases_search.xhtml')151 browser.get('http://marcmyuat.aan.com:8080/marcmy/pages/inpatient/cases/inpatient_cases_search.xhtml')152 Wait(5)153 # Find client's information using Admission ID154 browser.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[2]/table[1]/tbody/tr[1]/td[4]/input').send_keys(admNoList)155 Wait(5)156 browser.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[2]/table[1]/tbody/tr[11]/td[2]/button[1]').click()157 Wait(5)158 # Click client's name (a link)159 browser.find_element_by_xpath('/html/body/div[1]/div[3]/form/div[2]/div/div/div/div[3]/table/tbody/tr/td[4]/a').click()160 Wait(5)161 # Check id reference number is empty162 try:163 element_textare = '/html/body/div[1]/div[3]/form[1]/div[3]/div[2]/div/div/div[1]/table/tbody/tr[1]/td[2]/input'164 textare = browser.find_element_by_xpath(element_textare)165 refnum_value = textare.get_attribute('value')166 if refnum_value != '':167 print("Case ID [ %s ] is updated." % admNoList)168 refnum_updated.append(admNoList)169 audit_log("MSIG - Case ID [ %s ] is updated." % admNoList, "Completed...", msig_base)170 else:171 print("Case ID [ %s ] is not updated." % admNoList)172 refnum_notupdated.append(admNoList)173 audit_log("MSIG - Case ID [ %s ] is not updated." % admNoList, "Completed...", msig_base)174 except Exception:175 #print("checking refnum error")176 logging("MSIG - Automagica - Reference number value checking", error, msig_base)177 pass178 Wait(5)179 refnum_updateddf = pd.DataFrame(refnum_updated, columns = ['Updated Case ID'])180 refnum_notupdateddf = pd.DataFrame(refnum_notupdated, columns = ['Not Updated Case ID'])181 refnum_checkdf = pd.concat([refnum_updateddf, refnum_notupdateddf], axis=1)182 return refnum_checkdf183 184# Logout from Marc and close browser185def close_Marc(browser):186 try:187 browser.close()188 except Exception as error:...

Full Screen

Full Screen

shared-connection-cache.py

Source: shared-connection-cache.py Github

copy

Full Screen

...31@lcurl.lock_function32def my_lock(handle, data, locktype, useptr):33 print("-> Mutex lock", file=sys.stderr)34@lcurl.unlock_function35def my_unlock(handle, data, useptr):36 print("<- Mutex unlock", file=sys.stderr)37def main(argv=sys.argv[1:]):38 url: str = argv[0] if len(argv) >= 1 else "https://curl.se/"39 share: ct.POINTER(lcurl.CURLSH) = lcurl.share_init()40 lcurl.share_setopt(share, lcurl.CURLSHOPT_SHARE, lcurl.CURL_LOCK_DATA_CONNECT)41 lcurl.share_setopt(share, lcurl.CURLSHOPT_LOCKFUNC, my_lock)42 lcurl.share_setopt(share, lcurl.CURLSHOPT_UNLOCKFUNC, my_unlock)43 # Loop the transfer and cleanup the handle properly every lap. This will44 # still reuse connections since the pool is in the shared object!45 for i in range(3):46 curl: ct.POINTER(lcurl.CURL) = lcurl.easy_init()47 with curl_guard(False, curl):48 if not curl: continue49 lcurl.easy_setopt(curl, lcurl.CURLOPT_URL, url.encode("utf-8"))...

Full Screen

Full Screen

examine_outlierdb.py

Source: examine_outlierdb.py Github

copy

Full Screen

...3fn = 'OutlierDB.pickle'4my_lock(fn)5with open(fn, 'rb') as f:6 db = pickle.load(f)7my_unlock(fn)8print(len(db.sorted_index))9for k in db.sorted_index:...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

20 Best VS Code Extensions For 2023

With the change in technology trends, there has been a drastic change in the way we build and develop applications. It is essential to simplify your programming requirements to achieve the desired outcomes in the long run. Visual Studio Code is regarded as one of the best IDEs for web development used by developers.

Automated App Testing Using Appium With TestNG [Tutorial]

In recent times, many web applications have been ported to mobile platforms, and mobile applications are also created to support businesses. However, Android and iOS are the major platforms because many people use smartphones compared to desktops for accessing web applications.

How to Recognize and Hire Top QA / DevOps Engineers

With the rising demand for new services and technologies in the IT, manufacturing, healthcare, and financial sector, QA/ DevOps engineering has become the most important part of software companies. Below is a list of some characteristics to look for when interviewing a potential candidate.

An Interactive Guide To CSS Hover Effects

Building a website is all about keeping the user experience in mind. Ultimately, it’s about providing visitors with a mind-blowing experience so they’ll keep coming back. One way to ensure visitors have a great time on your site is to add some eye-catching text or image animations.

Top 7 Programming Languages For Test Automation In 2020

So you are at the beginning of 2020 and probably have committed a new year resolution as a tester to take a leap from Manual Testing To Automation . However, to automate your test scripts you need to get your hands dirty on a programming language and that is where you are stuck! Or you are already proficient in automation testing through a single programming language and are thinking about venturing into new programming languages for automation testing, along with their respective frameworks. You are bound to be confused about picking your next milestone. After all, there are numerous programming languages to choose from.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful