1
I’m trying to book a checkbox via webbrowser, but I’m not getting through.
HtmlElementCollection theElementCollection = default(HtmlElementCollection);
theElementCollection = doc.GetElementsByTagName("div");
foreach (HtmlElement curElement in theElementCollection)
{
if (curElement.GetAttribute("className").ToString() == "checkbox")
{
foreach (var item in curElement.All)
{
if (((HtmlElement)item).InnerText == null)
continue;
if (((HtmlElement)item).InnerText.Contains(" Windows 10") || ((HtmlElement)item).InnerText.Contains(" Windows XP")
|| ((HtmlElement)item).InnerText.Contains(" MS-DOS"))
{
((HtmlElement)item).SetAttribute("checked", "true");
}
}
}
if (curElement.GetAttribute("className").ToString() == "radio")
{
foreach (var item in curElement.All)
{
if (((HtmlElement)item).InnerText == null)
continue;
if (((HtmlElement)item).InnerText.Contains("Masculino"))
{
((HtmlElement)item).SetAttribute("checked", "true");
}
}
}
}
When I check the html
page it is setting the label checked="true
you’re catching the
HtmlElement
wrong only– Rovann Linhalis
managed to fix with ((Htmlelement)item).FirstChild.Setattribute("checked", "true");
– Marco Souza