Best Python code snippet using playwright-python
Open_SAP_Logon.py
Source:Open_SAP_Logon.py
...12from selenium.webdriver.common.keys import Keys13from selenium.webdriver.common.by import By14from selenium.common.exceptions import WebDriverException15# Add delay in the code for UI to catch up automation16def _pause(seconds):17 time.sleep(seconds)18def _click_pic_on_screen(pic, pause_time):19 pos = imagesearch(pic)20 if pos[0] != -1:21 print("position : ", pos[0], pos[1])22 pyautogui.moveTo(pos[0], pos[1])23 pyautogui.click()24 else:25 print("image not found")26 _pause(pause_time)27# START LOADING DATA28with open("moni_info.json", "r") as read_file:29 data = json.load(read_file)30syst_name = data['system']31conn = data['connection']32client = conn['client']33user = conn['username']34pw = conn['password']35transactions = data['transaction_info']36desktop = Desktop(backend="uia")37# END LOADING DATA38# START LOADING TRANSACTION TASKS39def SM12(sap_frontend_session):40 sap_frontend_session.type_keys('{TAB 3}')41 sap_frontend_session.type_keys("^a{BKSP}")42 sap_frontend_session.type_keys("*")43 sap_frontend_session.type_keys("{F8}")44def SM13(sap_frontend_session):45 sap_frontend_session.type_keys('{TAB 3}')46 sap_frontend_session.type_keys("^a{BKSP}")47 sap_frontend_session.type_keys("{F8}")48def SM21(sap_frontend_session):49 today = date.today()50 yesterday = today - timedelta(1)51 tomorrow = today + timedelta(1)52 sap_frontend_session.type_keys("^a{BKSP}")53 sap_frontend_session.type_keys(yesterday.strftime('%d.%m.%Y'))54 sap_frontend_session.type_keys('{TAB}')55 sap_frontend_session.type_keys('00:00:00')56 sap_frontend_session.type_keys('{TAB}')57 sap_frontend_session.type_keys(tomorrow.strftime('%d.%m.%Y'))58 sap_frontend_session.type_keys('{TAB 11}')59 sap_frontend_session.type_keys('{SPACE}')60 sap_frontend_session.type_keys('{TAB}')61 sap_frontend_session.type_keys("^a{BKSP}")62 sap_frontend_session.type_keys("{F8}")63 _pause(2)64def SM37(sap_frontend_session):65 today = date.today()66 yesterday = today - timedelta(1)67 tomorrow = today + timedelta(1)68 sap_frontend_session.type_keys('{TAB}')69 sap_frontend_session.type_keys("^a{BKSP}")70 sap_frontend_session.type_keys("*")71 sap_frontend_session.type_keys('{TAB 2}{SPACE}{TAB}{SPACE}{TAB 2}{SPACE}{TAB 2}')72 sap_frontend_session.type_keys("^a{BKSP}")73 sap_frontend_session.type_keys(yesterday.strftime('%d.%m.%Y'))74 sap_frontend_session.type_keys('{TAB}')75 sap_frontend_session.type_keys("^a{BKSP}")76 sap_frontend_session.type_keys(tomorrow.strftime('%d.%m.%Y'))77 sap_frontend_session.type_keys("{F8}")78 _pause(2)79def SM58(sap_frontend_session):80 today = date.today()81 start_date = today - timedelta(5)82 tomorrow = today + timedelta(1)83 sap_frontend_session.type_keys("^a{BKSP}")84 sap_frontend_session.type_keys(start_date.strftime('%d.%m.%Y'))85 sap_frontend_session.type_keys('{TAB}')86 sap_frontend_session.type_keys("^a{BKSP}")87 sap_frontend_session.type_keys(tomorrow.strftime('%d.%m.%Y'))88 sap_frontend_session.type_keys('{TAB 2}')89 sap_frontend_session.type_keys("^a{BKSP}")90 sap_frontend_session.type_keys("*")91 sap_frontend_session.type_keys("{F8}")92 _pause(2)93def SMICM(sap_frontend_session):94 sap_frontend_session.type_keys("+{F1}")95 _pause(0.5)96def SMQ(sap_frontend_session):97 sap_frontend_session.type_keys("^a{BKSP}")98 sap_frontend_session.type_keys("*")99 sap_frontend_session.type_keys("{F8}")100def SP01(sap_frontend_session):101 today = date.today()102 start_date = today - timedelta(1)103 sap_frontend_session.type_keys('{TAB 2}')104 sap_frontend_session.type_keys("^a{BKSP}")105 sap_frontend_session.type_keys("*")106 sap_frontend_session.type_keys('{TAB 2}')107 sap_frontend_session.type_keys("^a{BKSP}")108 sap_frontend_session.type_keys(start_date.strftime('%d.%m.%Y'))109 sap_frontend_session.type_keys("{F8}")110def SP12(sap_frontend_session):111 menu_item = sap_frontend_session.MenuItem(u'TemSe &Data Storage->Consistency chec&k')112 menu_item.Click()113 _pause(500)114def ST22(sap_frontend_session):115 today = date.today()116 start_date = today - timedelta(1)117 tomorrow = today + timedelta(1)118 sap_frontend_session.type_keys("^a{BKSP}")119 sap_frontend_session.type_keys(start_date.strftime('%d.%m.%Y'))120 sap_frontend_session.type_keys('{TAB}')121 sap_frontend_session.type_keys(tomorrow.strftime('%d.%m.%Y'))122 sap_frontend_session.type_keys('{TAB 11}')123 sap_frontend_session.type_keys("^a{BKSP}")124 sap_frontend_session.type_keys("{F8}")125 _pause(5)126def SXI_MONITOR(sap_frontend_session):127 today = date.today()128 start_date = today - timedelta(1)129 sap_frontend_session.type_keys('{TAB 2}')130 sap_frontend_session.type_keys('e{ENTER}')131 _pause(1)132 sap_frontend_session.type_keys('{TAB 2}')133 sap_frontend_session.type_keys("^a{BKSP}")134 sap_frontend_session.type_keys(start_date.strftime('%d.%m.%Y'))135 sap_frontend_session.type_keys('{TAB}')136 sap_frontend_session.type_keys('00:00:00')137 sap_frontend_session.type_keys("{F8}")138 _pause(2)139 # Checking if there is a information dialog that appeared140 try:141 sap_frontend_session = app.window(title_re='Information')142 sap_frontend_session.type_keys("{ENTER}")143 print('No errors found')144 except:145 _pause(3)146def WE05(sap_frontend_session):147 today = date.today()148 start_date = today - timedelta(1)149 sap_frontend_session.type_keys('{TAB 3}')150 sap_frontend_session.type_keys("^a{BKSP}")151 sap_frontend_session.type_keys(start_date.strftime('%d.%m.%Y'))152 sap_frontend_session.type_keys('{TAB 13}')153 sap_frontend_session.type_keys('51')154 sap_frontend_session.type_keys("{F8}")155 _pause(2)156 # Checking if there is a information dialog that appeared157 try:158 sap_frontend_session = app.window(title_re='Information')159 sap_frontend_session.type_keys("{ENTER}")160 print('No errors found')161 except:162 _pause(3)163def manual_steps(sap_frontend_session):164 print("Please complete manual steps for now")165 _pause(2)166 return167tasks = {168 'SM12': SM12,169 'SM13': SM13,170 'SM21': SM21,171 'SM37': SM37,172 'SM58':SM58,173 "SMICM": SMICM,174 "SMQ1": SMQ,175 "SMQ2": SMQ,176 "SOST": manual_steps,177 "SP01":SP01,178 "SP12":SP12,179 "ST06":manual_steps,180 "ST22":ST22,181 "SXI_MONITOR": SXI_MONITOR,182 "WE05":WE05183}184# END LOADING TRANSACTIONS TASKS185# START OPENING SAP LOGON #186try:187 print("Checking if App is already opened.")188 app = Application().Connect(path=r"C:\\Program Files (x86)\\SAP\\FrontEnd\\SAPgui\\saplogon.exe")189 dlg = app.Dialog190except:191 print("Opening App.")192 app = Application().Start(cmd_line=u'"C:\\Program Files (x86)\\SAP\\FrontEnd\\SAPgui\\saplogon.exe"')193 dlg = app.Dialog194 dlg.Wait('visible')195_pause(1)196print("Opening system instance.")197dlg.Button7.click() #list view198syst_list = dlg.listView199syst_list_txt = syst_list.texts()200# json_data = []201# data = ''202#203# for i in range(3, len(syst_list_txt), 7):204# data = {205# "client": "Dollarcity",206# "system": syst_list_txt[i]207# }208# json_data.append(data)209#210# with open('options.json', 'w') as outfile:211# json.dump(json_data, outfile)212try:213 syst_list.type_keys("{HOME}")214 syst_list.GetItem(syst_name).Click()215 dlg['Log&On'].Click()216except ValueError:217 print("Please add system in SAP logon")218 app.Kill_()219# END OPENING SAP LOGON220# START LOGIN USER AND SYSTEM221# dlg = desktop['SAP']222print("Login user.")223sap_frontend_session = app.window(class_name='SAP_FRONTEND_SESSION')224sap_frontend_session.type_keys(user + "{TAB}" + pw)225sap_frontend_session.type_keys("{TAB 21}")226sap_frontend_session.type_keys("^a{BKSP}"+client)227sap_frontend_session.type_keys("{ENTER}")228# END LOGIN USER AND SYSTEM229def _execute_transaction(transaction):230 print("Executing transaction " + transaction)231 sap_frontend_session = app.window(title_re='SAP Easy Access.*')232 transaction_box = sap_frontend_session.Edit233 transaction_box.SetEditText(transaction)234 sap_frontend_session.type_keys("{ENTER}")235def _back_to_main_win():236 print('Going back to main window.')237 sap_frontend_session = app.window(class_name='SAP_FRONTEND_SESSION')238 transaction_box = sap_frontend_session.Edit239 transaction_box.Click()240 transaction_box.SetEditText('/n')241 sap_frontend_session.type_keys("{ENTER}")242def _execute_tasks(transaction):243 print("Executing tasks related to " + transaction)244 sap_frontend_session = app.window(class_name='SAP_FRONTEND_SESSION')245 try:246 if transaction in tasks:247 tasks[transaction](sap_frontend_session)248 _pause(2)249 except KeyError:250 print('Could not find transaction tasks for ' + transaction)251 return252# START ENTER TRANSACTION253_pause(2)254for transaction in transactions:255 _execute_transaction(transaction)256 _pause(1)257 _execute_tasks(transaction)258 _pause(1)259 _back_to_main_win()260 _pause(1)261print("Execution completed.")262# END ENTER TRANSACTION263# window_name.print_control_identifiers()264# app.Kill_()265print("App terminated.")266print("Connection to PI Java stack")267# START OPENING SAP LOGON #268url ='http://abi-sapposrv.cicm.cmtek.com:50000/pimon'269# url = 'http://dp6.desco.com:53300/pimon'270try:271 driver = webdriver.Edge(executable_path=r'C:\Users\klu\Documents\SeleniumDriver\MicrosoftWebDriver.exe')272 driver.get(url)273 title = WebDriverWait(driver, 5).until(EC.title_contains('SAP'))274 print(driver.title)275 username = driver.find_element_by_name('j_username')276 username.send_keys(user)277 password = driver.find_element_by_name('j_password')278 password.send_keys(pw)279 password.send_keys(Keys.RETURN)280 _pause(10)281except WebDriverException as e:282 print(str(e))283except:284 print("Error occured...")285 driver.close()286# END OPENING SAP LOGON287# START GET TO MESSAGE MONITORING PAGE288_click_pic_on_screen('ref_pics/adapter_engine.png', 5)289_click_pic_on_screen('ref_pics/message_monitor.png', 10)290_click_pic_on_screen('ref_pics/database.png', 2)291# END GET TO MESSAGE MONITORING PAGE292# START MESSAGE MONITORING STEPS293def _apply_filter(driver, char_filter):294 msg_filter = driver.find_element_by_id('CEPJICNK.MessageFilterView.FindStatus')295 msg_filter.click()296 _pause(0.5)297 msg_filter.send_keys(char_filter)298 msg_filter.send_keys(Keys.RETURN)299driver.switch_to.window(driver.window_handles[1])300time_period = driver.find_element_by_id('CEPJICNK.MessageFilterView.TimePeriodDropDown')301time_period.click()302_pause(0.5)303time_period.send_keys(Keys.ARROW_UP)304time_period.send_keys(Keys.RETURN)305_pause(5)306today = date.today()307start_date = today - timedelta(1)308startDate = driver.find_element_by_name('CEPJICNK.MessageFilterView.StartInputField')309startDate.clear()310startDate.send_keys(start_date.strftime('%d/%m/%Y'))311_pause(0.5)312startTime = driver.find_element_by_id('CEPJICNK.MessageFilterView.StartInputField:A')313startTime.clear()314startTime.send_keys('12:00:00 AM')315startTime.send_keys(Keys.RETURN)316_pause(1)317filters = ['a', 'w', 'h', 'u']318for char_filter in filters:319 _apply_filter(driver, char_filter)320 _click_pic_on_screen('ref_pics/go.png', 2)321# driver.close()322# END MESSAGE MONITORING STEPS323# Close tab and switch to original tab324driver.close()325driver.switch_to.window(driver.window_handles[0])326# START COMMUNICATION CHANNEL MONITORING327# Get to channel monitoring page328_click_pic_on_screen('ref_pics/communication_channel.png', 3)329driver.switch_to.window(driver.window_handles[1])330channel_status = driver.find_element_by_id('CEPJICNK.SearchView.Status')331channel_status.click()332_pause(0.5)333channel_status.send_keys('c')334channel_status.send_keys(Keys.RETURN)335_click_pic_on_screen('ref_pics/go.png', 2)336driver.close()337# END COMMUNICATION CHANNEL MONITORING338driver.switch_to.window(driver.window_handles[0])...
circularMouseAreaClick.py
Source:circularMouseAreaClick.py
1import pyautogui2import random3import time4def performLeftClick(loc):5 pyautogui.leftClick(6 None,7 None,8 # 0,9 # random.uniform(0.3, 0.7)10 )11def sleepRandom(smallInt, largeInt):12 sleep = random.uniform(smallInt, largeInt)13 print(sleep)14 # time.sleep(sleep)15def shuffleRandomize(loc, type, max):16 foo = 017 if (type == 'add'):18 # print("("+str(loc)+"+"+str(time.time())[-1:], end="")19 # print(")+"+str(random.randint(3, max)), end="")20 foo = (loc+int(str(time.time())[-1:]))+(random.randint(3, max)*1)21 # print("=" + str(foo))22 else:23 # print("("+str(loc)+"-"+str(time.time())[-1:], end="")24 # print(")-"+str(random.randint(3, max)), end="")25 foo = (loc-int(str(time.time())[-1:]))-(random.randint(3, max)*1)26 # print("=" + str(foo))27 return foo28def drawArea(loc, max):29 pyautogui.press('x')30 pyautogui.press('[')31 pyautogui.press('[')32 for x in range(0, max, 10):33 pyautogui.click(loc[0]+9+(max*1), loc[1]+9+(max*1), _pause=False)34 pyautogui.dragTo(loc[0]-9-(max*1), loc[1]+9+(max*1), _pause=False)35 pyautogui.dragTo(loc[0]-9-(max*1), loc[1]-9-(max*1), _pause=False)36 pyautogui.dragTo(loc[0]+9+(max*1), loc[1]-9-(max*1), _pause=False)37 pyautogui.dragTo(loc[0]+9+(max*1), loc[1]+9+(max*1), _pause=False)38 # pyautogui.dragTo(loc[randLoc][0]-x, loc[randLoc][1]+x)39 # pyautogui.dragTo(loc[randLoc][0]+x, loc[randLoc][1]+x, button='left')40 # pyautogui.dragTo(loc[randLoc][0]+x, loc[randLoc][1]-x, button='left')41 # pyautogui.dragTo(loc[randLoc][0]-x, loc[randLoc][1]-x, button='left')42 pyautogui.press('x')43 pyautogui.press(']')44 pyautogui.press(']')45max = 5 # input("Max pixels to go out to ")46go = "y"47clickSpeed = 0.12548total = 049offsetLoc = [3, 5, 2]50loc = []51foo = input("Mouse over first position ")52# loc[0] = pyautogui.position()53# loc.append([3042, 1066])54loc.append(pyautogui.position())55# pyautogui.leftClick(loc[0][0], loc[0][1], _pause=False)56foo = input("Mouse over first position ")57# loc[1] = pyautogui.position()58loc.append(pyautogui.position())59foo = input("Mouse over first position ")60# loc[2] = pyautogui.position()61loc.append(pyautogui.position())62# loc[0] = [3406, 1298]63pyautogui.leftClick(loc[0][0], loc[0][1], _pause=False)64# loc[0] = [3042, 1066]65# print(format_time())66print(loc[0])67# foo = input("Mouse over first position ")68pyautogui.leftClick(loc[0][0], loc[0][1], _pause=False)69pyautogui.press('delete')70pyautogui.press('p')71drawArea(loc[0], max)72drawArea(loc[1], max)73drawArea(loc[2], max)74while(go == "y"):75 for x in range(1, 250):76 # print(x)77 # current = pyautogui.position()78 # if (79 # (current[0] >= loc[randLoc][0]+12 or current[0] <= loc[randLoc][0]-12) and80 # (current[1] >= loc[randLoc][1]+12 or current[1] <= loc[randLoc][1]-12)81 # ):82 randLoc = random.randint(0, 2)83 randNumber = random.randint(1, 4)84 if(randNumber == 1):85 pyautogui.click(86 random.randint(87 shuffleRandomize(loc[randLoc][0], 'sub', max),88 shuffleRandomize(loc[randLoc][0], 'add', max)89 ),90 random.randint(91 shuffleRandomize(loc[randLoc][1], 'sub', max),92 shuffleRandomize(loc[randLoc][1], 'add', max)93 ),94 _pause=False,95 duration=clickSpeed96 )97 elif(randNumber == 2):98 pyautogui.click(99 random.randint(100 shuffleRandomize(loc[randLoc][0]-offsetLoc[0], 'sub', max),101 shuffleRandomize(loc[randLoc][0]-offsetLoc[0], 'add', max)102 ),103 random.randint(104 shuffleRandomize(loc[randLoc][1]-offsetLoc[1], 'sub', max),105 shuffleRandomize(loc[randLoc][1]-offsetLoc[1], 'add', max)106 ),107 _pause=False,108 duration=clickSpeed109 )110 elif(randNumber == 3):111 pyautogui.click(112 random.randint(113 shuffleRandomize(loc[randLoc][0]+offsetLoc[1], 'sub', max),114 shuffleRandomize(loc[randLoc][0]+offsetLoc[1], 'add', max)115 ),116 random.randint(117 shuffleRandomize(loc[randLoc][1]+offsetLoc[2], 'sub', max),118 shuffleRandomize(loc[randLoc][1]+offsetLoc[2], 'add', max)119 ),120 _pause=False,121 duration=clickSpeed122 )123 elif(randNumber == 4):124 pyautogui.click(125 random.randint(126 shuffleRandomize(loc[randLoc][0]+offsetLoc[2], 'sub', max),127 shuffleRandomize(loc[randLoc][0]+offsetLoc[2], 'add', max)128 ),129 random.randint(130 shuffleRandomize(loc[randLoc][1]+offsetLoc[0], 'sub', max),131 shuffleRandomize(loc[randLoc][1]+offsetLoc[0], 'add', max)132 ),133 _pause=False,134 duration=clickSpeed135 )136 print("==== " + str(x) + " =======")137 # sleepRandom(0.9, 1.4)138 # pyautogui.click(duration=clickSpeed, _pause=False)139 # performLeftClick(loc[0])140 # sleepRandom(0.3, 0.7)141 # performLeftClick(loc[0])142 # sleepRandom(30.6, 52.5)143 total = total + 250144 foo = input("clicked: " + str(total) + " another? (y|n) ")...
__init__.py
Source:__init__.py
1import time2import Quartz345keyboardMapping = ({6 'a': 0x00, 's': 0x01, 'd': 0x02, 'f': 0x03, 'h': 0x04, 'g': 0x05, 'z': 0x06, 'x': 0x07, 'c': 0x08,7 'v': 0x09, 'b': 0x0b, 'q': 0x0c, 'w': 0x0d, 'e': 0x0e, 'r': 0x0f, 'y': 0x10, 't': 0x11, '1': 0x12,8 '!': 0x12, '2': 0x13, '@': 0x13, '3': 0x14, '#': 0x14, '4': 0x15, '$': 0x15, '6': 0x16, '^': 0x16,9 '5': 0x17, '%': 0x17, '=': 0x18, '+': 0x18, '9': 0x19, '(': 0x19, '7': 0x1a, '&': 0x1a, '-': 0x1b,10 '_': 0x1b, '8': 0x1c, '*': 0x1c, '0': 0x1d, ')': 0x1d, ']': 0x1e, '}': 0x1e, 'o': 0x1f, 'u': 0x20,11 '[': 0x21, '{': 0x21, 'i': 0x22, 'p': 0x23, 'l': 0x25, 'j': 0x26, "'": 0x27, '"': 0x27, 'k': 0x28,12 ';': 0x29, ':': 0x29, '\\': 0x2a, '|': 0x2a, ',': 0x2b, '<': 0x2b, '/': 0x2c, '?': 0x2c, 'n': 0x2d,13 'm': 0x2e, '.': 0x2f, '>': 0x2f, '`': 0x32, '~': 0x32, ' ': 0x31, 'space': 0x31, '\r': 0x24,14 '\n': 0x24, 'enter': 0x24, 'return': 0x24, '\t': 0x30, 'tab': 0x30, 'backspace': 0x33, '\b': 0x33,15 'esc': 0x35, 'escape': 0x35, 'command': 0x37, 'shift': 0x38, 'shiftleft': 0x38, 'capslock': 0x39,16 'option': 0x3a, 'optionleft': 0x3a, 'alt': 0x3a, 'altleft': 0x3a, 'ctrl': 0x3b, 'ctrlleft': 0x3b,17 'shiftright': 0x3c, 'optionright': 0x3d, 'ctrlright': 0x3e, 'fn': 0x3f, 'f17': 0x40,18 'volumeup': 0x48, 'volumedown': 0x49, 'volumemute': 0x4a,19 'help': 0x72, 'pageup': 0x74, 'pgup': 0x74, 'del': 0x75, 'delete': 0x75, 'f4': 0x76, 'end': 0x77, 'f2': 0x78,20 'pagedown': 0x79, 'pgdn': 0x79, 'f1': 0x7a, 'left': 0x7b, 'right': 0x7c, 'down': 0x7d, 'up': 0x7e,21 'yen': 0x5d, 'underscore': 0x5e, 'comma': 0x5f, 'eisu': 0x66, 'kana': 0x68,22})2324for c in 'abcdefghijklmnopqrstuvwxyz':25 keyboardMapping[c.upper()] = keyboardMapping[c]262728def _isShiftCharacter(character):29 return character.isupper() or character in '~!@#$%^&*()_+{}|:"<>?'303132def _autoPause(_pause):33 if _pause:34 time.sleep(0.1)353637def keyUpDown(upDown, key, _pause=True):38 assert upDown in ('up', 'down'), "upDown argument must be 'up' or 'down'"3940 key = key.lower() if len(key) > 1 else key41 if key not in keyboardMapping or keyboardMapping[key] is None:42 return4344 try:45 if _isShiftCharacter(key):46 key_code = keyboardMapping[key.lower()]4748 event = Quartz.CGEventCreateKeyboardEvent(None, keyboardMapping['shift'], upDown == 'down')49 Quartz.CGEventPost(Quartz.kCGHIDEventTap, event)50 time.sleep(0.01)5152 else:53 key_code = keyboardMapping[key]5455 event = Quartz.CGEventCreateKeyboardEvent(None, key_code, upDown == 'down')56 Quartz.CGEventPost(Quartz.kCGHIDEventTap, event)57 time.sleep(0.01)5859 except KeyError:60 raise RuntimeError("Key %s not implemented." % key)6162 _autoPause(_pause)636465def press(keys, _pause=True):66 keys = [keys] if type(keys) == str else keys6768 for k in keys:69 keyUpDown('down', k, _pause=False)70 keyUpDown('up', k, _pause=False)7172 _autoPause(_pause)737475def typewrite(message, _pause=True):76 for s in message:77 press(s, _pause=False)7879 _autoPause(_pause)808182def hotkey(*args, **kwargs):83 for _c in args:84 keyUpDown('down', _c, _pause=False)8586 for _c in reversed(args):87 keyUpDown('up', _c, _pause=False)88
...
timer.py
Source:timer.py
...13 return self._pause14 @property15 def splits(self):16 return self._split_list17 def start_pause(self):18 # if not self._start_time and not self._split_list and self._pause:19 if self._start_time is None:20 self._start_time = 021 if self._pause_time is None:22 self._pause_time = 023 if self._pause:24 self._start_time = (self._start_time25 + time.perf_counter_ns()26 - self._pause_time)27 self._pause = not self._pause28 print('timer unpaused')29 elif self._start_time and not self._pause:30 self._pause_time = time.perf_counter_ns()31 self._pause = not self._pause32 print('timer paused')33 def start(self):34 if self.paused:35 self.start_pause()36 def pause(self):37 if not self.paused:38 self.start_pause()39 def reset(self):40 if self.paused:41 self._start_time = None42 self._pause_time = None43 self._split_list = []44 self._pause = True45 def split(self):46 if not self.paused:47 self._split_list.append(self.get_formatted())48 def get(self):49 if self._pause and self._start_time is None:50 return 051 elif self._pause and not self._start_time is None:52 return self._pause_time - self._start_time...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!