Reputation: 63
Maybe its just me being a little dumb but I can't find a way to input text into the fields on a website using C#, I have tried looking at HTML agility pack and some javascript injection, but can't find a simple or smart way to do this. Let me come with an example.
Here a html snip from a online website:
<fieldset>
<input type="text" autocomplete="off" placeholder="Vejnavn, husnummer, postnummer" id="autocomplete-adgangsadresse2" class="span3 ui-autocomplete-input">
</fieldset>
I would like to inject some text in so the field to make a automatic seach for me.
Any ideas on how to do this?
Upvotes: -1
Views: 308
Reputation: 959
Try this using HTMLAgilityPack:
var doc = web.Load(url);
HtmlNode node = doc.DocumentNode.SelectNodes("//input[@id='autocomplete-adgangsadresse2']").First();
if (node != null) {
node.SetAttributeValue("value", "new value");
}
Upvotes: 0