In Selenium, you can’t use .sendKeys() directly on an element like a hidden input since such fields are not visible in the DOM. Here use JavaScript instead to set the input to a desired value.
Here is an approach to do that:
1. Locate the element.
2, Use Javascript to set the value.
The code to modify your hidden input’s value is given below:
// Locate the specific element
WebElement element = driver.findElement(By.xpath("//*[@id='invoice_supplier_id']"));
// Change the value using js
((JavascriptExecutor) driver).executeScript("arguments[0].value='desired_value';", element);
Change ‘desired_value’ to the value that one wants to set to the invoice_supplier_id.
This piece of code uses JavaScript to set the value property of the hidden input directly.