0 votes
1 view
in Devops and Agile by (17.7k points)

I have an element in my code that looks like this:

<input id="invoice_supplier_id" name="invoice[supplier_id]" type="hidden" value="">

I want to set its value, so I created a web element with it's xpath:

val test = driver.findElements(By.xpath("""//*[@id="invoice_supplier_id"]"""))

but now I dont see an option to set the value.

1 Answer

0 votes
by (48.1k points)

Use findElement instead of findElements


driver.findElement(By.xpath("//input[@id='invoice_supplier_id'])).sendKeys("your value");



driver.findElement(By.xpath("//input[@id='invoice_supplier_id'])).setAttribute("value", "your value")



driver.findElement(By.id("invoice_supplier_id")).setAttribute("value", "your value");

I hope this helps!