2

I need set value in Hidden inputfield of my webpage, I am using Selenium 2. I tried with webelement.sendKeys(value), but its not working.

Can anybody tell me how to do this ?

Thanks.

SmartSolution
  • 2,320
  • 5
  • 37
  • 49

2 Answers2

1

That question seems a little bit out of the box. Selenium is simulating user-based interactions. So, that's pointless to expecting from a user editing hidden elements on the page. But may be you should say why do you need this and what are you trying to do with this function, it can be more easy to finding some workarounds for it.

mirza
  • 5,685
  • 10
  • 43
  • 73
  • I am agree with you, Actually there is major difference between Selenium 1 & Selenium 2, previously we were using Selenium 1 which supports manipulating of hidden HTML elements by default, but Selenium 2 doesn't, I need this access else many tests need to be modified :( , so I am trying to access hidden element in IE using selenium2 by XPath, I am using JavascriptExecutor.exucuteScript() & executing script, with that I can access hidden element in Firefox but For IE i m not able find proper javascript code to access hidden element using XPath. – SmartSolution Mar 23 '11 at 08:02
0

You can't modify the hidden object using element methods. Instead, send script to the driver:

@driver.execute_script("document.getElementById('context-menu-upload').value=#{value}")

Here is the documentation: execute_script(script, *args)

To use xpath instead, try this: Is there a way to get element by XPath using JavaScript in Selenium WebDriver?

Community
  • 1
  • 1
Marc Kubischta
  • 193
  • 1
  • 4