66 # Console Domain Disabled
77 'test_console.py' ,
88
9- # query_selector is deprecated
10- 'test_queryselector.py' ,
11- 'test_element_handle.py' ,
12- 'test_element_handle_wait_for_element_state.py' ,
13-
149 # https://github.com/Kaliiiiiiiiii-Vinyzu/patchright/issues/31
1510 'test_route_web_socket.py'
1611]
5247 # Disable Popup Blocking
5348 "test_page_event_should_have_an_opener" ,
5449
55- # query_selector is deprecated
56- "test_should_work_with_layout_selectors" ,
57- "test_should_dispatch_click_event_element_handle" ,
58- "test_should_dispatch_drag_and_drop_events_element_handle" ,
59-
6050 # Minor Differences in Call Log. Deemed Unimportant
6151 "test_should_be_attached_fail_with_not" ,
6252 "test_add_script_tag_should_include_source_url_when_path_is_provided" ,
53+ # / Black Formatting
54+ "test_should_collect_sources" ,
55+ "test_should_record_trace_with_source" ,
6356
6457 # Server/Client Header Mismatch
6558 "test_should_report_request_headers_array" ,
6962
7063dont_isolate_evaluation_tests = [
7164 "test_timeout_waiting_for_stable_position" ,
72- "test_jshandle_evaluate_accept_object_handle_as_argument" ,
73- "test_jshandle_evaluate_accept_nested_handle" ,
74- "test_jshandle_evaluate_accept_nested_window_handle" ,
75- "test_jshandle_evaluate_accept_multiple_nested_handles" ,
76- "test_should_dispatch_drag_drop_events" ,
77- "test_should_dispatch_drag_and_drop_events_element_handle" ,
7865 "track_events" ,
79- "captureLastKeydown" ,
8066 "test_expose_function_should_work_on_frames_before_navigation" ,
67+ "test_should_dispatch_drag_drop_events" ,
68+ "test_should_dispatch_drag_and_drop_events_element_handle" ,
8169]
8270
8371# Reason for skipping tests_backup
@@ -131,10 +119,14 @@ def process_file(file_path):
131119 test_name = current_node .name
132120
133121 if test_name in dont_isolate_evaluation_tests :
134- # Don't add isolated_context=False to these tests
122+ # # Don't add isolated_context=False to these tests
135123 continue
136124
137- if node .func .attr in ("evaluate" , "evaluate_handle" , "evaluate_all" ) and isinstance (node .func .value , ast .Name ) and node .func .value .id in ("page" , "popup" , "button" , "new_page" , "page1" , "page2" , "target" , "page_1" , "page_2" , "frame" ):
125+ if (node .func .attr in ("evaluate" , "evaluate_handle" , "evaluate_all" )
126+ and isinstance (node .func .value , ast .Name )
127+ and node .func .value .id in ("page" , "popup" , "button" , "new_page" , "page1" , "page2" , "target" , "page_1" , "page_2" , "frame" )
128+ and not (node .func .value .id == "button" and "element_handle" in file_path )
129+ ):
138130 node .keywords .append (ast .keyword (arg = 'isolated_context' , value = ast .Constant (value = False )))
139131
140132 modified_source = ast .unparse (ast .fix_missing_locations (file_tree ))
@@ -213,5 +205,21 @@ def main():
213205 if file .endswith ('.py' ):
214206 process_file (file_path )
215207
208+ if file == "test_queryselector.py" :
209+ with open (file_path , 'r' , encoding = 'utf-8' ) as f :
210+ content = f .read ()
211+
212+ # Replace the full quoted strings with valid Python expressions (not strings)
213+ content = content .replace (
214+ "assert await page.eval_on_selector_all('isolated=ignored', 'es => window.__answer !== undefined')" ,
215+ """await page.evaluate('() => window.__answer = document.querySelector("span")', isolated_context=True)\n assert await page.eval_on_selector_all('isolated=ignored', 'es => window.__answer !== undefined')"""
216+ ).replace (
217+ "assert page.eval_on_selector_all('isolated=ignored', 'es => window.__answer !== undefined')" ,
218+ """page.evaluate('() => window.__answer = document.querySelector("span")', isolated_context=True)\n assert page.eval_on_selector_all('isolated=ignored', 'es => window.__answer !== undefined')"""
219+ )
220+
221+ with open (file_path , 'w' , encoding = 'utf-8' ) as f :
222+ f .write (content )
223+
216224if __name__ == '__main__' :
217225 main ()
0 commit comments