Reading hidden field values with Selenium

I have a need to hide a guid used for an index on a .cshtml so I can get model binding on controls dynamically added with ajax (it’s a long story) (that was a mouthful)

I had a hard time finding the value in the hidden field; as it turns out, you can just get it by the attribute on the Selenium element like this:


IWebElement hiddenIndex = driver.FindElement(By.Id("MyControlName_0__Index"));
var indexValueToUse = hiddenIndex.GetAttribute("value");

 

1 thought on “Reading hidden field values with Selenium

  1. ?render=@layoutModel.yourPublicKey.

    Hi there Mr. Sowers, You don’t mention any information about ?render=@layoutModel.yourPublicKey… where is this layout.Model? Do we make this?

    Thanks

Leave a reply to App Dev Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.