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.

3
  • 2
    Possible duplicate of Set hidden input value in Selenium? Commented Jun 11, 2016 at 9:59
  • @Joucks No, that removes hidden feature of field and types data also I want an alternative method in .net Commented Jun 11, 2016 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 minimal reproducible example, 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. Commented Jul 10, 2016 at 23:45

1 Answer 1

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");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.