开发者

is it possible to interact with hidden elements in selenium2?

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.


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.


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜