How to select option in a dropdown when the html-tag has a random id



  • I have a problem how to select a desired option (e.g. From, To...etc.) from list if 'datalist id' and 'select name' are randomly generated. This means that the ID and name has another value after refresh page. Here is a code for a first row, and 1st Field list:

    enter image description here

    I tried the lower described solutions, but there is no text value, as shown in the following figure. enter image description here



  • It is a matter of proper xpath. You know the row and the column. You also know that the select is under datalist. The thing that is left to do is //table[@id='advFilter']/tbody/tr[N]/td[@class='field']/datalist/select. Where N is the row number. You can extend this xpath so that it captures the particular option if you need.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2