Martin McInnes
Martin McInnes

Reputation: 1

java selenium - hidden input value

First Stack post, so don't be harsh if I get it wrong.

Im using selenium and java for some automated testing. All was going well until I tried to set the value of a hidden input.

When using 'type' in the Firefox IDE, it works a treat, but when I use the line below, it doesn't play at all. It just fails.

// This line doesnt like to run because its hidden
selenium.type("name=startDate_submit", "2015-09-25");

Can anyone point me in the right direction.

Many Thanks.

Edit:

WebDriver driver = new ChromeDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("$([name=startDate_submit]).attr('type', 'text');");
Thread.sleep(3000);
// This line doesnt like to run because its hidden
selenium.type("name=startDate_submit", "2015-09-25");

Should this be the way I do this? I just cannot get it working.

Upvotes: 0

Views: 2564

Answers (2)

sibi
sibi

Reputation: 174

just try with this command,

driver.findElement(By.xpath("path")).sendKeys("value");

but make sure you have clicked that path before providing input value. come back if you still have any problem.

Upvotes: 2

Try with available javascript commads like document.getElementById, then set the value.

Upvotes: 0

Related Questions