3

We are unable to locate and click at an element with "aria-selected" = "false" on an HTML page. We have tried different way to write xpath locator and css selector but none of them worked. While inspecting a bit more on page, we found that this element has a "aria-selected="false" in it and when we click on it and it shows results then this value changes to "aria-selected="true"

enter image description here

We have tried with below xpath:

(".//*/span[@class='tab-button-text'][contains(text(),'Orders')]")

Note: Even though it does not matter which framework, we are using to use this element. However i would like to mention that, we have been trying it for two separate framework such as

  1. Karate framework and other one,
  2. Selenium, Cucumber BDD with java
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Niks
  • 85
  • 6
  • Why is JavaScript tagged? – evolutionxbox Nov 23 '21 at 01:05
  • my karate feature file is ''' Given driver 'https://test.com' ''' > * delay(5000) > * waitFor(".//*/span[@class='tab-button-text'][contains(text(),'Orders')]") > When click(".//*/span[@class='tab-button-text'][contains(text(),'Orders')]") * delay(6000) – Niks Nov 23 '21 at 01:12
  • CSS selector `'*[aria-label="sidebar"]'` – nlta Nov 23 '21 at 01:20
  • Hi @nlta , i am getting error with css selector as well 'loginOMS.feature:6 - evaluation (js) failed: click('*[aria-label="sidebar"]'), java.lang.RuntimeException: js eval failed twice:document.querySelector("*[aria-label="sidebar"]").click(), error: {"type":"object","subtype":"error","className":"SyntaxError","description":"SyntaxError: missing ) after argument list","objectId":"-137200642617226304.1.7"} stack trace: com.intuit.karate.driver.DevToolsDriver.eval(DevToolsDriver.java:300)' – Niks Nov 23 '21 at 01:47

1 Answers1

2

ariaSelected

The ariaSelected property of the Element interface reflects the value of the aria-selected attribute, which indicates the current "selected" state of elements that have a selected state.

Value: A DOMString with one of the following values:

  • true: The item is selected.
  • false: The item is not selected.

Selected/unselected state of this WebElement attribute doesn't effects your tests.


To locate the element you can you can use either of the following Locator Strategies:

  • xpath:

    ("//span[@class='tab-button-text' and contains(text(),'Orders')]")
    
  • cssSelector:

    ("div.tabbar.show-tabbar > a.tab-button.has-title.has-icon span.tab-button-text")
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352