Can't set value by input index

Can someone help me change the value of my input.
The problem is that I have several inputs with the same CssSelector:

so I would like to be able to choose them by index and selenium, but …

Can you direct me to get there please


Sorry not read clearly your issue :slight_smile:
you have already used CSS Selectors

try to use CSS Selector as locator
in browser
inspect --> copy --> CSS Selector

and use javascript
String js = ‘document.querySelector("#my-button").click();’
WebUI.executeJavaScript(js, null)
some info will found here

1 Like


what about javascript document.getElementsByClassName(“class-name”)[0].click()

getElementsByClassName will return list so you can try to search your inputs as index


You can either locate all of the inputs and gather them into a list, then access each input by giving an index to that list (pseudocode):

List<WebElement> inputs = ... // locate all <input> elements

… or you can provide an index in your locator that will return ONLY the element at a given index (pseudocode):

WebElement input = ... // include desired index in whichever locator you are using
1 Like

Thank you very much Brandon


I were to use the WebElment list and its index.