0

I am getting error while entering text into hidden fields using .sendkeys() in web automation using selenium and chrome driver.

I got one similar question here, but I am not getting how to implement it in .Net

How to do it ?

I am using vb.net but c# is also OK for me.

Community
  • 1
  • 1
IT researcher
  • 3,274
  • 17
  • 79
  • 143
  • 2
    Possible duplicate of [Set hidden input value in Selenium?](http://stackoverflow.com/questions/8917612/set-hidden-input-value-in-selenium) – Joucks Jun 11 '16 at 09:59
  • @Joucks No, that removes hidden feature of field and types data also I want an alternative method in .net – IT researcher Jun 11 '16 at 11:58
  • What have you tried and what was the result? Please read the help topics on how to ask a good question. You need to research your own issue, find code samples, etc. and write your own code to solve the issue. If you do all that and still can't figure it out, then come back and edit your question and add notes from the research you did, the code you have tried reduced to a [mcve], and what the result was... any error messages, etc. It's also very important to include any relevant HTML and properly format the HTML and code. – JeffC Jul 10 '16 at 23:45

1 Answers1

2

As far as I know, you have to use IJSExecutor. See an example below:

string script = "arguments[0].setAttribute('value', arguments[1]);"
IWebElement theHiddenField = driver.FindElement(By.Id("the-hidden-field"));
((IJavaScriptExecutor)driver).ExecuteScript(script, theHiddenField, "here is new value");
Buaban
  • 5,029
  • 1
  • 17
  • 33