How to use wait_until_loaded method in toolium

Best Python code snippet using toolium_python

pocket.py

Source:pocket.py Github

copy

Full Screen

...33 new_y = y - (START_DIMS['y'] - int(self.start_dims['y']))34 new_y = round(new_y * (float(self.resolution['y'])/float(RESOLUTION['y'])))35 return (new_x, new_y)36 37 def wait_until_loaded(self, x, y, pixels=[], timeout=None):38 x, y = self.transform_position(x, y)39 im = pyautogui.screenshot(region=(x, y, 5, 5))40 count = 041 current_pixel = im.getpixel((0, 0))42 43 condition = not [p for p in pixels 44 if ((current_pixel[0] in range(p[0]-10, p[0]+10)) and 45 (current_pixel[1] in range(p[1]-10, p[1]+10)) and46 (current_pixel[2] in range(p[2]-10, p[2]+10)))]47 if timeout is not None:48 current_time = time.time()49 condition = condition and time.time() < current_time + timeout 50 51 while condition:52 time.sleep(0.1)53 im = pyautogui.screenshot(region=(x, y, 5, 5))54 current_pixel = im.getpixel((0, 0))55 56 condition = not [p for p in pixels 57 if ((current_pixel[0] in range(p[0]-10, p[0]+10)) and 58 (current_pixel[1] in range(p[1]-10, p[1]+10)) and59 (current_pixel[2] in range(p[2]-10, p[2]+10)))]60 if timeout is not None:61 condition = condition and time.time() < current_time + timeout62 63 count += 164 if count % 50 == 0:65 print('have waited for %s iterations' % count)66 print('position is: %s,%s' % (x,y))67 print('current_pixel is: %s,%s,%s' % current_pixel)68 number = 169 for pixel in pixels:70 print('expected %s pixel is: %s,%s,%s' % (number, pixel[0], pixel[1], pixel[2]))71 number += 172 73 if count > 1200:74 print('Failed after %s attempts' % count)75 sys.exit()76 77 number = 178 for p in pixels:79 if ((current_pixel[0] in range(p[0]-10, p[0]+10)) and 80 (current_pixel[1] in range(p[1]-10, p[1]+10)) and81 (current_pixel[2] in range(p[2]-10, p[2]+10))):82 return number83 else:84 number += 1 85 86 def repeat_until_loaded(self, x1, y1, x2, y2, pixels=[], timeout=None, max_attempts=2, attempts=0):87 self.moveTo(x1, y1)88 time.sleep(0.3)89 90 self.click(x1, y1, button='left')91 time.sleep(0.5)92 93 if attempts >= max_attempts:94 match = self.wait_until_loaded(x2, y2, pixels=pixels)95 else: 96 match = self.wait_until_loaded(x2, y2, pixels=pixels, timeout=timeout)97 time.sleep(1)98 99 print('Match: %s, Attempts: %s' % (match, attempts))100 101 if match is not None:102 return match103 else:104 print('Repeating again')105 self.repeat_until_loaded(x1, y1, x2, y2, pixels=pixels, timeout=timeout, attempts=attempts+1)106 def open_bluestacks(self):107 print('Opening BlueStacks')108 pyautogui.click(328, 1053, button='left')109 self.wait_until_loaded(161, 133, pixels=[(51, 58, 97)])110 print('Opened BlueStacks')111 112 def close_bluestacks(self):113 print('Closing bluestacks')114 pyautogui.click(1781, 29, button='left')115 time.sleep(2)116 self.wait_until_loaded()117 def open_my_apps(self):118 print('Opening My Apps and starting Pocket Evolution')119 pyautogui.click(207, 84, button='left')120 time.sleep(0.2)121 pyautogui.click(368, 190, button='left')122 # Wait until game opened123 self.wait_until_loaded(957, 876, pixels=[(228, 100, 74)])124 time.sleep(0.5)125 126 def start_pocket_evolution(self):127 print('Starting game')128 pyautogui.click(957, 876, button='left')129 self.wait_until_loaded(969, 189, pixels=[(237, 192, 153), (134, 210, 246)])130 # Wait an extra 5 seconds for notification to pop up if it's going to131 print('Waiting for notification if necessary')132 time.sleep(5)133 match = self.wait_until_loaded(969, 189, pixels=[(237, 192, 153), (134, 210, 246)])134 135 if match == 1:136 print('Closing notification')137 pyautogui.click(1523, 172, button='left')138 print('Notification closed, waiting 2 seconds')139 time.sleep(2)140 141 def open_champions_tower(self):142 print('Opening Champions Tower')143 self.repeat_until_loaded(814, 248, 961, 188, pixels=[(246, 102, 32)], timeout=3)144 time.sleep(0.5)145 def challenge_area(self, area, buff=False):146 print('Challenging area %s' % area['id'])147 x, y = area['position']148 149 self.wait_until_loaded(x, y, pixels=[(area['pixel'])], timeout=3)150 151 print('Waiting for challenge')152 self.repeat_until_loaded(x, y, 1436, 517, pixels=[(233, 104, 76)], timeout=3)153 print('Waiting for hero selection for fight')154 self.repeat_until_loaded(1436, 517, 1183, 810, pixels=[(233, 103, 75)], timeout=3)155 print('Waiting until fight completion')156 self.repeat_until_loaded(1183, 810, 1174, 485, pixels=[(3, 224, 17)], timeout=3, max_attempts=15)157 print('Fight completed')158 159 if buff is True:160 print('Getting buff')161 self.repeat_until_loaded(1174, 485, 970, 279, pixels=[(211, 95, 240)], timeout=3)162 print('Waiting on return to tower')163 self.repeat_until_loaded(715, 643, 971, 452, pixels=[(98, 99, 102)], timeout=3)164 else:165 print('Waiting on return to tower')166 self.repeat_until_loaded(1174, 485, 971, 452, pixels=[(98, 99, 102)], timeout=3)167 168 time.sleep(0.5)169 170 def play_champions_tower(self):171 print('Playing Champions Tower')172 print('Check if a reset is needed')173 print('Check if last chest was opened')174 175 last_chest_opened = False176 match = self.wait_until_loaded(715, 303, pixels=[(74, 51, 26)], timeout=3)177 if match == 1:178 last_chest_opened = True179 180 resetable = False181 match = self.wait_until_loaded(1391, 832, pixels=[(229, 100, 74)], timeout=3)182 if match == 1:183 resetable = True184 185 if last_chest_opened and resetable:186 print('Reseting tower')187 self.repeat_until_loaded(1391, 832, 784, 666, pixels=[(233, 104, 76)], timeout=3)188 time.sleep(0.5)189 self.repeat_until_loaded(784, 666, 971, 452, pixels=[(98, 99, 102)], timeout=3)190 time.sleep(0.5)191 192 areas_pre_buff_1 = [{'id': 1, 'position': (1219, 724), 'pixel': (102, 204, 88)},193 {'id': 2, 'position': (1079, 715), 'pixel': (102, 214, 88)}]194 area_buff_1 = {'id': 3, 'position': (943, 703), 'pixel': (102, 216, 95)}195 area_chest_1 = {'id': 4, 'position': (812, 674), 'pixel': (102, 208, 89)}196 197 for area in areas_pre_buff_1:198 self.challenge_area(area)199 self.challenge_area(area_buff_1, buff=True)200 self.challenge_area(area_chest_1)201 202 print('Getting chest 1')203 self.repeat_until_loaded(699, 571, 941, 243, pixels=[(239, 183, 29)], timeout=5)204 match = self.repeat_until_loaded(699, 571, 971, 452, pixels=[(98, 99, 102), (231, 223, 208)], timeout=3)205 if match == 2:206 print('Equipment max. Reseting dialog')207 self.repeat_until_loaded(800, 641, 971, 452, pixels=[(98, 99, 102)], timeout=3)208 209 area_pre_buff_2 = {'id': 5, 'position': (853, 523), 'pixel': (102, 213, 91)}210 area_buff_2 = {'id': 6, 'position': (1006, 511), 'pixel': (102, 218, 92)}211 area_chest_2 = {'id': 7, 'position': (1169, 494), 'pixel': (102, 206, 95)}212 213 self.challenge_area(area_pre_buff_2)214 self.challenge_area(area_buff_2, buff=True)215 self.challenge_area(area_chest_2)216 217 print('Getting chest 2')218 self.repeat_until_loaded(1358, 417, 941, 243, pixels=[(239, 183, 29)], timeout=5)219 match = self.repeat_until_loaded(1358, 417, 971, 452, pixels=[(98, 99, 102), (231, 223, 208)], timeout=3)220 if match == 2:221 print('Equipment max. Reseting dialog')222 self.repeat_until_loaded(800, 641, 971, 452, pixels=[(98, 99, 102)], timeout=3)223 224 area_pre_buff_3 = {'id': 8, 'position': (1185, 340), 'pixel': (102, 210, 91)}225 area_buff_3 = {'id': 9, 'position': (1041, 334), 'pixel': (106, 219, 91)}226 area_chest_3 = {'id': 10, 'position': (890, 332), 'pixel': (255, 255, 255)}227 #area_chest_3 = {'id': 10, 'position': (889, 306), 'pixel': (84, 163, 201)}228 229 self.challenge_area(area_pre_buff_3)230 self.challenge_area(area_buff_3, buff=True)231 self.challenge_area(area_chest_3)232 233 print('Getting chest 3')234 self.repeat_until_loaded(738, 304, 941, 243, pixels=[(239, 183, 29)], timeout=5)235 match = self.repeat_until_loaded(738, 304, 971, 452, pixels=[(98, 99, 102), (231, 223, 208)], timeout=3)236 if match == 2:237 print('Equipment max. Reseting dialog')238 self.repeat_until_loaded(800, 641, 971, 452, pixels=[(98, 99, 102)], timeout=3)239 240 print('Champions Tower done')241 else:242 print('Last chest opened: %s, Resetable: %s' % (last_chest_opened, resetable))243 sys.exit() 244 245 def go_to_wonderland(self):246 print('Going to Wonderland')247 self.moveTo(228, 500)248 pyautogui.dragRel(self.transform_position(1400,0)[0], 0, 1, button='left')249 self.moveTo(228, 500)250 pyautogui.dragRel(self.transform_position(1000,0)[0], 0, 0.6, button='left')251 self.repeat_until_loaded(396, 367, 396, 367, pixels=[(56, 122, 164)], timeout=3)252 time.sleep(0.5)253 254 def open_exploration(self):255 print('Opening Exploration')256 self.moveTo(228, 500)257 pyautogui.dragRel(self.transform_position(400,0)[0], 0, 0.3, button='left')258 self.moveTo(417, 528)259 time.sleep(0.3)260 self.repeat_until_loaded(417, 528, 967, 127, pixels=[(243, 102, 26)], timeout=3)261 print('Opened Exploration')262 time.sleep(1)263 def check_exploration_slot(self, slot):264 x, y = slot265 self.click(x, y, button='left')266 267 print('Checking for receving exploration goods normally')268 match = self.wait_until_loaded(941, 243, pixels=[(239, 183, 29)], timeout=5)269 time.sleep(0.5)270 271 if match is None:272 print('Not normal performing extra checks')273 274 print('Checking if we are in hero selection')275 match = self.wait_until_loaded(280, 841, pixels=[(229, 99, 74)], timeout=5)276 if match == 1:277 print ('We are in hero selection, skip this hero')278 self.click(1736, 182, button='left')279 self.wait_until_loaded(967, 127, pixels=[(244, 102, 23)])280 time.sleep(0.5)281 return282 283 print('Checking if we are resetting exploration time')284 match = self.wait_until_loaded(1130, 621, pixels=[(233, 104, 76)], timeout=5)285 if match == 1:286 print ('We are resetting this heros time')287 self.click(1130, 621, button='left')288 self.wait_until_loaded(941, 243, pixels=[(239, 183, 29)])289 time.sleep(0.3)290 print('Waiting on return to exploration')291 self.click(1130, 621, button='left')292 self.wait_until_loaded(967, 127, pixels=[(244, 102, 23)])293 time.sleep(0.3)294 return295 else:296 print('Waiting on return to exploration')297 self.click(x, y, button='left')298 self.wait_until_loaded(967, 127, pixels=[(244, 102, 23)])299 time.sleep(0.3)300 301 def send_on_exploration(self, slot):302 x, y = slot303 print('Waiting for hero selection')304 self.repeat_until_loaded(x, y, 280, 841, pixels=[(229, 99, 74)], timeout=3)305 print('Waiting for time selection')306 self.repeat_until_loaded(280, 841, 719, 670, pixels=[(233, 103, 76)], timeout=3)307 print('Waiting on return to exploration')308 self.repeat_until_loaded(719, 670, 967, 127, pixels=[(244, 102, 23)], timeout=3)309 310 def check_and_send_on_exploration(self):311 print('Checking slots')312 slots = [(710, 715), ...

Full Screen

Full Screen

mapper.py

Source:mapper.py Github

copy

Full Screen

...39NUL = {} # nonmapped (invalid) output region40if is_shapely_speedups_available():41 shapely.speedups.enable()42 log.debug('Shapely speed-ups available')43def wait_until_loaded(func):44 @wraps(func)45 def wrapper(*args, **kwargs):46 global is_done_loading47 while not is_done_loading:48 time.sleep(.1)49 if isinstance(is_done_loading, Exception):50 raise is_done_loading51 return func(*args, **kwargs)52 return wrapper53is_done_loading = False54def init():55 global is_done_loading56 def _admin_cc(filename):57 parts = path.basename(filename).split('.', 1)[0].split('-')...

Full Screen

Full Screen

test_issue_details.py

Source:test_issue_details.py Github

copy

Full Screen

...40 )41 self.browser.get(42 u'/{}/{}/issues/{}/'.format(self.org.slug, self.project.slug, event.group.id)43 )44 self.wait_until_loaded()45 self.browser.snapshot('issue details python')46 def test_cocoa_event(self):47 event = self.create_sample_event(48 platform='cocoa',49 )50 self.browser.get(51 u'/{}/{}/issues/{}/'.format(self.org.slug, self.project.slug, event.group.id)52 )53 self.wait_until_loaded()54 self.browser.snapshot('issue details cocoa')55 def test_unity_event(self):56 event = self.create_sample_event(57 default='unity',58 platform='csharp'59 )60 self.browser.get(61 u'/{}/{}/issues/{}/'.format(self.org.slug, self.project.slug, event.group.id)62 )63 self.wait_until_loaded()64 self.browser.snapshot('issue details unity')65 def test_aspnetcore_event(self):66 event = self.create_sample_event(67 default='aspnetcore',68 platform='csharp'69 )70 self.browser.get(71 u'/{}/{}/issues/{}/'.format(self.org.slug, self.project.slug, event.group.id)72 )73 self.wait_until_loaded()74 self.browser.snapshot('issue details aspnetcore')75 def test_javascript_specific_event(self):76 event = self.create_sample_event(77 platform='javascript'78 )79 self.browser.get(80 u'/{}/{}/issues/{}/events/{}/'.format(self.org.slug,81 self.project.slug, event.group.id, event.id)82 )83 self.wait_until_loaded()84 self.browser.snapshot('issue details javascript - event details')85 self.browser.find_element_by_xpath("//a//code[contains(text(), 'curl')]").click()86 self.browser.snapshot('issue details javascript - event details - curl command')87 def test_rust_event(self):88 # TODO: This should become its own "rust" platform type89 event = self.create_sample_event(90 platform='native',91 sample_name='Rust',92 )93 self.browser.get(94 u'/{}/{}/issues/{}/'.format(self.org.slug, self.project.slug, event.group.id)95 )96 self.wait_until_loaded()97 self.browser.snapshot('issue details rust')98 def test_cordova_event(self):99 event = self.create_sample_event(100 platform='cordova'101 )102 self.browser.get(103 u'/{}/{}/issues/{}/'.format(self.org.slug, self.project.slug, event.group.id)104 )105 self.wait_until_loaded()106 self.browser.snapshot('issue details cordova')107 def test_stripped_event(self):108 event = self.create_sample_event(109 platform='pii'110 )111 self.browser.get(112 u'/{}/{}/issues/{}/'.format(self.org.slug, self.project.slug, event.group.id)113 )114 self.wait_until_loaded()115 self.browser.snapshot('issue details pii stripped')116 def test_empty_exception(self):117 event = self.create_sample_event(118 platform='empty-exception'119 )120 self.browser.get(121 u'/{}/{}/issues/{}/'.format(self.org.slug, self.project.slug, event.group.id)122 )123 self.wait_until_loaded()124 self.browser.snapshot('issue details empty exception')125 def test_empty_stacktrace(self):126 event = self.create_sample_event(127 platform='empty-stacktrace'128 )129 self.browser.get(130 u'/{}/{}/issues/{}/'.format(self.org.slug, self.project.slug, event.group.id)131 )132 self.wait_until_loaded()133 self.browser.snapshot('issue details empty stacktrace')134 def test_invalid_interfaces(self):135 event = self.create_sample_event(136 platform='invalid-interfaces'137 )138 self.browser.get(139 u'/{}/{}/issues/{}/'.format(self.org.slug, self.project.slug, event.group.id)140 )141 self.wait_until_loaded()142 self.browser.click('.errors-toggle')143 self.browser.wait_until('.entries > .errors ul')144 self.browser.snapshot('issue details invalid interfaces')145 def test_activity_page(self):146 event = self.create_sample_event(147 platform='python',148 )149 self.browser.get(150 u'/{}/{}/issues/{}/activity/'.format(151 self.org.slug, self.project.slug, event.group.id)152 )153 self.browser.wait_until('.activity-item')154 self.browser.snapshot('issue activity python')155 def wait_until_loaded(self):156 self.browser.wait_until_not('.loading-indicator')157 self.browser.wait_until('.entries')158 self.browser.wait_until('[data-test-id="linked-issues"]')...

Full Screen

Full Screen

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 toolium 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