How to differentiate between 2 drop downs having similar ID (with changing only last 3 digits) on the same page?

StackOverflow https://stackoverflow.com/questions/23408059

  •  13-07-2023
  •  | 
  •  

Question

In my application in one of the create screen i have 2 drop downs having similar ID as below:

1st drop down ID: j_idt129_label

&

2nd drop down ID: j_idt147_label

Now i want to select a value from the first dropdown.

One way is By considering the XPATH without considering the dropdown's ID.

Is there any other way for this?

Was it helpful?

Solution

I think this would work for you. This will select the first dropdown:

(//select[contains(@id, 'j_itd')])[1]

To find the second one:

(//select[contains(@id, 'j_itd')])[2]

select is the tag I'm guessing is in your HTML, but you may need to update select to match the actual tag.

OTHER TIPS

Are the drop down ID's (three digits) are keep on changing? If not, then you can directly use them, else, consider corresponding parent element and get its child (drop down) elements.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top