Skip to content Skip to sidebar Skip to footer

Can Selenium Recognize Aria-uuid As An ID For Object Recognition?

I recently recommended to my devs to add IDs to each element on the project I'm working to make automation more robust, they added in aria-uuid to each element. I cannot get anythi

Solution 1:

Ideally, yes you should have been able to recognize each individual elements with respect to their aria-uuid to be used with Selenium provided the generated aria-uuid were static.

As per the HTML you have shared the generated aria-uuid seems to be dynamic. So aria-uuid alone won't help you. In these cases you have to use the aria-uuid along with the other attributes to uniquely identify the elements. To identify this element you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver_init, delay1).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.short.ng-valid.ng-not-empty.ng-valid-min.ng-valid-required[aria-uuid$='_input'][name^='question_']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver_init, delay1).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='short ng-valid ng-not-empty ng-valid-min ng-valid-required' and contains(@aria-uuid, '_input')][starts-with(@name, 'question_')]"))).click()
    

Solution 2:

It should be possible with a CSS selector [aria-uuid='question_16_input']


Post a Comment for "Can Selenium Recognize Aria-uuid As An ID For Object Recognition?"