使用
findElement代替
findElements
driver.findElement(By.xpath("//input[@id='invoice_supplier_id'])).sendKeys("your value");要么
driver.findElement(By.id("invoice_supplier_id")).sendKeys("value", "your value");或使用JavascriptExecutor
WebElement element = driver.findElement(By.xpath("enter the xpath here")); // you can use any locator JavascriptExecutor jse = (JavascriptExecutor)driver; jse.executescript("arguments[0].value='enter the value here';", element);要么
(JavascriptExecutor) driver.executescript("document.evaluate(xpathExpresion, document, null, 9, null).singleNodevalue.innerHTML="+ DesiredText);或(使用javascript)
driver.findElement(By.xpath("//input[@id='invoice_supplier_id'])).setAttribute("value", "your value")希望它能对您有所帮助:)



