Skip to content

Commit

Permalink
more updates to selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Malar-Natarajan committed Aug 15, 2024
1 parent a0e97f8 commit 2adc2ff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions pytest-selenium/pages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@


BOUNDING_RECTANGLE = "return arguments[0].getBoundingClientRect();"
XPATH_SEARCH = "//span[contains(text(),'{term}') and contains(@class,'search-highlight first text last focus')]"
XPATH_SEARCH = "//mark[contains(text(), '{term}') and (@aria-current='true') and (@class='search-highlight first text last')]"
# If search term is inside a block of search highlight use this XPATH
XPATH_SEARCH_BLOCK = (
"//span[contains(@class,'search-highlight text last focus') and contains(text(),'{term}')]"
)
XPATH_SEARCH_BLOCK = "//mark[contains(text(), '{term}') and (@aria-current='true') and (@class='search-highlight text last')]"


class Page(pypom.Page):
Expand Down
2 changes: 1 addition & 1 deletion pytest-selenium/regions/search_sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SearchSidebar(Region):
_search_result_locator = (By.CSS_SELECTOR, "[data-testid$=result]")
_search_results_sidebar_locator = (
By.XPATH,
"//div[@data-testid = 'search-results-sidebar']/div[2]",
"//div[@data-testid = 'search-results-sidebar']/nav",
)

# fmt: off
Expand Down
4 changes: 1 addition & 3 deletions pytest-selenium/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,7 @@ def test_highlight_entire_search_element(selenium, base_url, book_slug, page_slu
book.assert_search_term_is_highlighted_in_content_page(search_term)

# THEN: Entire search element is highlighted in content page
xpath_search_block = (
"//span[contains(@class,'search-highlight text last focus')][contains(text(),'{term}')]"
)
xpath_search_block = "//mark[contains(text(), '{term}') and (@aria-current='true') and (@class='search-highlight text last')]"
focussed_search_term = book.find_elements(By.XPATH, xpath_search_block.format(term=search_term))

try:
Expand Down

0 comments on commit 2adc2ff

Please sign in to comment.