C# webBrowser automatic submit button click not working

Viewed 46

I have a button in HTML as such:

<input id="accept” class="accept button" type="submit" name="authorize" value="Log in" style>

The code below not working.

HtmlElementCollection elc = this.webBrowser1.Document.GetElementsByTagName("input");  
foreach (HtmlElement el in elc)  
{  
   if (el.GetAttribute("type").Equals("submit"))  
   {  
        el.InvokeMember("Click");  
   }  
 }

I have also tried:

          HtmlElementCollection classButton = webBrowser1.Document.All;
            foreach (HtmlElement element in classButton)
            {
                if (element.GetAttribute("class").Contains("accept"))
                {
                    element.InvokeMember("click");
                }
            }

But no success.

1 Answers

did you try this?

var lLink = driver.FindElement(By.CssSelector(".accept.button"));
lLink.Click();

look doc

Related