1

I have a datepicker table on a web page. It has 2 dropdowns for 'Month' and 'Year', like below: enter image description here

enter image description here

I am able to locate the dropdown boxes. However, the peculiar issue is that, when I am trying to select any of those dropdowns or select any element using Javascript from the dropdowns, the locators get generated with any random number, like below: document.querySelector("#ptcs-dropdown-list-5081360000002384")

This number is arbitrary and keeps changing each time the page is refreshed. Therefore, it makes no sense hardcoding the number in the locator.

I have managed to locate 1 of the dropdown boxes with the following code, but unable to select the other dropdowns with the same code. path_yr = "document.querySelector("[id^='ptcs-dropdown-list']").shadowRoot.querySelector('#root > div > div:nth-child(3) > ptcs-list-item:nth-child("+str(yrow)+")').click()"

            time.sleep(2)
            driver.execute_script(path_yr)

The issue might be due to some developmental structure. How to tackle it?

Difference between this question and Other questions!!! I am getting random arbitrary number when forming the locators, therefore trying to create a locator as generic as possible, however, it only works for 1 dropdown not others. This issue of arbitrary number is not present in any other questions on the portal!!

0 Answers0