|
2 | 2 | import re |
3 | 3 | import time |
4 | 4 | from typing import Literal |
| 5 | +from urllib.parse import urlparse |
5 | 6 |
|
6 | 7 | from selenium.common.exceptions import StaleElementReferenceException, TimeoutException |
7 | 8 | from selenium.webdriver import ActionChains, Firefox |
@@ -407,6 +408,28 @@ def verify_search_mode_is_not_visible(self): |
407 | 408 | self.element_not_visible("search-mode-chicklet") |
408 | 409 | return self |
409 | 410 |
|
| 411 | + @BasePage.context_chrome |
| 412 | + def verify_search_mode_label(self, engine_name: str): |
| 413 | + """Verify that the search mode chicklet displays the correct engine.""" |
| 414 | + chicklet = self.get_element("search-mode-chicklet") |
| 415 | + chip_text = ( |
| 416 | + chicklet.text or chicklet.get_attribute("aria-label") or "" |
| 417 | + ).lower() |
| 418 | + assert engine_name.lower() in chip_text, ( |
| 419 | + f"Expected search mode engine '{engine_name}', got '{chip_text}'" |
| 420 | + ) |
| 421 | + return self |
| 422 | + |
| 423 | + @BasePage.context_chrome |
| 424 | + def verify_plain_text_in_input_awesome_bar(self, expected_text: str): |
| 425 | + """Verify the awesomebar input contains the exact literal text.""" |
| 426 | + input_el = self.get_element("awesome-bar") |
| 427 | + value = input_el.get_attribute("value") |
| 428 | + assert value == expected_text, ( |
| 429 | + f"Expected input '{expected_text}', got '{value}'" |
| 430 | + ) |
| 431 | + return self |
| 432 | + |
410 | 433 | def click_first_suggestion_row(self): |
411 | 434 | """ |
412 | 435 | Clicks the first visible suggestion row in the list, using robust scrolling and fallback. |
@@ -920,6 +943,27 @@ def verify_status_panel_url(self, expected_url: str): |
920 | 943 | f"Expected '{expected_url}' in status panel URL, got '{actual_url}'" |
921 | 944 | ) |
922 | 945 |
|
| 946 | + @BasePage.context_content |
| 947 | + def verify_domain(self, expected_domain: str) -> None: |
| 948 | + """ |
| 949 | + Verify that the current URL's domain matches the expected domain using urlparse. |
| 950 | + This explicitly checks the domain (netloc) rather than just a substring match. |
| 951 | + Uses content context to get the actual page URL. |
| 952 | +
|
| 953 | + Argument: |
| 954 | + expected_domain: The expected domain (e.g., "wikipedia.org", "google.com") |
| 955 | + """ |
| 956 | + |
| 957 | + def _domain_matches(_): |
| 958 | + parsed = urlparse(self.driver.current_url) |
| 959 | + return expected_domain in parsed.netloc |
| 960 | + |
| 961 | + self.custom_wait(timeout=15).until(_domain_matches) |
| 962 | + parsed_url = urlparse(self.driver.current_url) |
| 963 | + assert expected_domain in parsed_url.netloc, ( |
| 964 | + f"Expected '{expected_domain}' domain, got '{parsed_url.netloc}'" |
| 965 | + ) |
| 966 | + |
923 | 967 | @BasePage.context_chrome |
924 | 968 | def verify_engine_returned(self, engine: str) -> None: |
925 | 969 | """ |
|
0 commit comments