1

When creating a Watir script that clicks a right pagination arrow, I can't seem to find a solution to grabbing the bottom 'kat-icon' tag: https://i.stack.imgur.com/oYFKR.jpg

Tried using a lot of different versions of the line below but nothing seems to work.

browser.element(id: 'mas-apps-store-search-paginator').span(name: 'chevron-right').exists?

How should I approach this?

alvaro88
  • 55
  • 5
  • Screenshots of the UI are great, screenshots of HTML are not. Please post the relevant HTML as text in your question and properly format it. – JeffC Aug 21 '22 at 15:38

2 Answers2

0

I would first try a simple CSS selector like

#mas-apps-store-search-paginator kat-icon[name='chevron-right']

I'm kinda assuming that won't work due to the shadow-root. In that case, you'd need to do something like

shadow_host = driver.find_element(id: 'mas-apps-store-search-paginator')
shadow_root = shadow_host.shadow_root
icon = shadow_root.find_element(name: 'chevron-right')
JeffC
  • 22,180
  • 5
  • 32
  • 55
0

Given the HTML:

kat-icon

the <kat-icon> element is within a #shadow-root (open)


Solution

To identify and click on the <kat-icon> element you can use the following locator strategies:

shadow_host = browser.find_element(css: 'kat-pagination.mas-paginator')
shadow_root = shadow_host.shadow_root
right_pagination_arrow = shadow_root.find_element(css: 'kat-icon.nav__icon[name="chevron-right"]')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352