@@ -72,13 +72,10 @@ def test_url_is_present_in_history(browser_history: History, selenium: WebDriver
7272 browser_history .open_history_menu ()
7373 history_items = browser_history .history_items ()
7474 with selenium .context (selenium .CONTEXT_CHROME ):
75- is_present = False
76- for item in history_items :
77- image_attr = item .get_attribute ("image" )
78- if image_attr is not None :
79- is_present = url in image_attr
80- if is_present :
81- break
75+ is_present = any (
76+ (image_attr := item .get_attribute ("image" )) and url in image_attr
77+ for item in history_items
78+ )
8279 assert is_present
8380
8481
@@ -106,13 +103,15 @@ def test_verify_links_open_in_new_tab_from_history(
106103 panel_ui .open_history_menu ()
107104 history_items = browser_history .history_items ()
108105 with selenium .context (selenium .CONTEXT_CHROME ):
109- found_urls = []
110- for link in links :
111- for item in history_items :
112- image_attr = item .get_attribute ("image" )
113- if image_attr is not None and link in image_attr :
114- found_urls .append (link )
115- break
106+ found_urls = [
107+ link
108+ for link in links
109+ if any (
110+ image_attr is not None and link in image_attr
111+ for item in history_items
112+ if (image_attr := item .get_attribute ("image" ))
113+ )
114+ ]
116115 assert len (found_urls ) == 3
117116
118117
@@ -128,13 +127,15 @@ def test_verify_links_open_in_new_window_from_history(
128127 panel_ui .open_history_menu ()
129128 history_items = browser_history .history_items ()
130129 with selenium .context (selenium .CONTEXT_CHROME ):
131- found_urls = []
132- for link in links :
133- for item in history_items :
134- image_attr = item .get_attribute ("image" )
135- if image_attr is not None and link in image_attr :
136- found_urls .append (link )
137- break
130+ found_urls = [
131+ link
132+ for link in links
133+ if any (
134+ image_attr is not None and link in image_attr
135+ for item in history_items
136+ if (image_attr := item .get_attribute ("image" ))
137+ )
138+ ]
138139 assert len (found_urls ) == 3
139140
140141
@@ -151,11 +152,8 @@ def test_clear_recent_history(
151152 panel_ui .open_history_menu ()
152153 history_items = browser_history .history_items ()
153154 with selenium .context (selenium .CONTEXT_CHROME ):
154- is_present = False
155- for item in history_items :
156- image_attr = item .get_attribute ("image" )
157- if image_attr is not None :
158- is_present = url in image_attr
159- if is_present :
160- break
155+ is_present = any (
156+ (image_attr := item .get_attribute ("image" )) and url in image_attr
157+ for item in history_items
158+ )
161159 assert not is_present
0 commit comments