0 votes
1 view
in Devops and Agile by (25k 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 (63.3k 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!

For further knowledge on Selenium, go for Selenium tutorial or Selenium training course by Intellipaat.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !