@@ -20,28 +20,33 @@ def set_timeout(self, timeout):
2020 See the Timeout section above for more information.
2121
2222 Example:
23-
23+
2424 | Open page that loads slowly | | |
2525 | Set Timeout | ${orig timeout} | |
2626
2727 """
2828 orig_timeout = self .ctx .timeout
29- self .ctx .get_current_library_context ().set_default_timeout (timestr_to_secs (timeout ))
29+ if self .ctx .get_current_library_context ().browser_type .lower () == 'ptchrome' :
30+ self .ctx .get_current_library_context ().set_default_timeout (timestr_to_secs (timeout ))
31+ else :
32+ self .loop .run_until_complete (
33+ self .ctx .get_current_library_context ().set_default_timeout (timestr_to_secs (timeout ))
34+ )
3035 self .info ('Original timeout is ' + str (orig_timeout ) + ' seconds' )
3136 return orig_timeout
3237
3338 @keyword
3439 def run_async_keywords_and_return_first_completed (self , * keywords ):
3540 """Executes all the given keywords in a asynchronous and wait until first keyword is completed
36-
41+
3742 ``Return`` Array of result for each keywords based on index
3843
3944 Example
4045 | `Run Async Keywords And Return First Completed` | Wait for response url | ${HOME_PAGE_URL}/login.html | AND |
4146 | ... | Wait for response url | ${HOME_PAGE_URL}/home.html | |
4247 """
4348 run_keyword = _RunKeyword ()
44- return self .loop .run_until_complete ( self ._run_async_keywords_first_completed (run_keyword ._split_run_keywords (list (keywords ))) )
49+ return self .loop .run_until_complete (self ._run_async_keywords_first_completed (run_keyword ._split_run_keywords (list (keywords ))))
4550
4651 @keyword
4752 def run_async_keywords (self , * keywords ):
@@ -56,7 +61,7 @@ def run_async_keywords(self, *keywords):
5661
5762 """
5863 run_keyword = _RunKeyword ()
59- return self .loop .run_until_complete ( self ._run_async_keywords (run_keyword ._split_run_keywords (list (keywords ))) )
64+ return self .loop .run_until_complete (self ._run_async_keywords (run_keyword ._split_run_keywords (list (keywords ))))
6065
6166 @keyword
6267 def enable_debug_mode (self , slowMo = 150 , devtools = True ):
@@ -89,11 +94,12 @@ async def disable_debug_mode_async():
8994 self .ctx .debug_mode = False
9095 self .ctx .clear_browser ()
9196
92- async def _run_async_keywords (self , iterable ):
97+ async def _run_async_keywords (self , iterable ):
9398 statements = []
9499 for kw , args in iterable :
95100 kw_name = kw .lower ().replace (' ' , '_' )
96- async_keywords = self .ctx .keywords [kw_name ].__self__ .get_async_keyword_group ()
101+ async_keywords = self .ctx .keywords [kw_name ].__self__ .get_async_keyword_group (
102+ )
97103 statements .append (getattr (async_keywords , kw_name )(* args ))
98104 try :
99105 return await asyncio .gather (* statements )
@@ -105,8 +111,10 @@ async def _run_async_keywords_first_completed(self, iterable):
105111 index = 0
106112 for kw , args in iterable :
107113 kw_name = kw .lower ().replace (' ' , '_' )
108- async_keywords = self .ctx .keywords [kw_name ].__self__ .get_async_keyword_group ()
109- org_statements .append (self ._wrapped_async_keyword_return_index (index , getattr (async_keywords , kw_name )(* args ) ))
114+ async_keywords = self .ctx .keywords [kw_name ].__self__ .get_async_keyword_group (
115+ )
116+ org_statements .append (self ._wrapped_async_keyword_return_index (
117+ index , getattr (async_keywords , kw_name )(* args )))
110118 index += 1
111119 statements = org_statements
112120 error_stack_trace = ''
@@ -128,9 +136,9 @@ async def _run_async_keywords_first_completed(self, iterable):
128136 error_stack_trace += str (e )+ '\n '
129137 continue
130138 if len (pending ) == 0 :
131- raise Exception ("All async keywords failed \r \n " + error_stack_trace )
139+ raise Exception (
140+ "All async keywords failed \r \n " + error_stack_trace )
132141
133142 async def _wrapped_async_keyword_return_index (self , index , future ):
134143 await future
135144 return index
136-
0 commit comments