When working with Selenium WebDriver, I am facing difficulties selecting the
<input class="cs-autocomplete-input" tabindex="">
element due to its fluid ID. This is because there are multiple items with the same class name on the web page, making it challenging to pinpoint the specific element. Is there a way to effectively locate elements like this despite their dynamic IDs? Using By.className("cs-autocomplete-input")
doesn't work in this case.
<div class="content">
<div id="fluid-id-bhlpjo3p-1026">
<input type="button" class="csc-repeatable-add-bhlpjo3p-1022 cs-repeatable-add" value="+">
<ul class="cs-repeatable">
<li class="csc-repeatable-repeat-bhlpjo3p-1022 clearfix cs-repeatable-repeat show">
<input type="radio" class="csc-repeatable-primary-bhlpjo3p-1022 show cs-repeatable-primary" name="primary-fields.sponsors" value="true">
<input type="text" class="csc-exhibition-sponsor cs-repeatable-content" id="repeat::.csc-exhibition-sponsor" name="repeat::.csc-exhibition-sponsor" style="display: none;">
<input class="cs-autocomplete-input" tabindex="">
<a href="#" class="cs-autocomplete-closebutton" title="Cancel edit, and return this field to the most recent authority value" style="display: none;"></a>
<input type="button" value="" class="csc-repeatable-delete-bhlpjo3p-1022 cs-repeatable-delete" disabled="">
</li>
</ul>
</div>
For reference, the xpath of this div is
//*[@id="primaryTab"]/div/div[3]/div[1]/div[2]/div[2]/div[1]/div/div[2]