title: Need VBA code snippet for selenium to click on a web page element
body: <p>I previously used the following code snippet to click on a selector button in a web page that was opened in internet explorer.</p>
  <pre><code>Set inputSelector = HTMLDoc.getElementsByClassName(&quot;idp&quot;) '&lt;== the collection of input tags on the page
      For Each MyHTML_Element In inputSelector
          If MyHTML_Element.className = &quot;idp&quot; Then 
             MyHTML_Element.Click: Exit For
          End If
      Next
  </code></pre>
  <p>I tried to find the same button in the &quot;idp&quot; class with Selenium using</p>
  <pre><code>   Set inputBoxes = htmlDoc.FindElementByCss(&quot;idp&quot;).Text 
  </code></pre>
  <p>which is from an example I found on-line.  This snippet generates a compiler error because .Text is a string and I'm seeking a collection.  What should I use in place of FindElementByCss().Text to return a collection?</p>
  <pre><code>Public Sub Sample()
      Dim pid As Long
      Dim pno As Long: pno = 17556
      Dim htmlDoc As WebDriver
      
  'Create Selenium htmlDoc, Verify MS Edge Webdriver and continue
      Set htmlDoc = CreateObject(&quot;Selenium.WebDriver&quot;)
      pid = StartEdgeDriver(PortNo:=pno)
      If pid = 0 Then Exit Sub
      
  'Specify URL, create Selenium html document and open webpage
      sLoginURL = &quot;https://empowercentral.ussco.com/&quot;
      htmlDoc.StartRemotely &quot;http://localhost:&quot; &amp; pno &amp; &quot;/&quot;, &quot;MicrosoftEdge&quot;
      htmlDoc.Get sLoginURL    
  
  Set inputSelector = htmlDoc.FindElementByCss(&quot;idp&quot;).Text
  For Each MyHTML_Element In inputSelector
      If MyHTML_Element.className = &quot;idp&quot; Then 
         MyHTML_Element.Click: Exit For
      End If
  Next
  
      htmlDoc.FindElementById(&quot;userNameInput&quot;).SendKeys &quot;username&quot;
      htmlDoc.FindElementById(&quot;nextButton&quot;).Click
      htmlDoc.FindElementById(&quot;passwordInput&quot;).SendKeys &quot;password&quot;
      htmlDoc.FindElementById(&quot;submitButton&quot;).Click
  
  
  End Sub
  </code></pre>
  <p>Here is the html from the website that I'm trying to scrape:
  
  Sign in with one of these accounts</p>
  <pre><code>        &lt;input id=&quot;hrdSelection&quot; type=&quot;hidden&quot;&gt;
          &lt;div class=&quot;idp&quot; tabindex=&quot;1&quot; onkeypress=&quot;if (event &amp;amp;&amp;amp; (event.keyCode == 32 || event.keyCode == 13)) HRD.selection('http://login.essendant.com/adfs/services/trust');&quot; onclick=&quot;HRD.selection('http://login.essendant.com/adfs/services/trust'); return false;&quot;&gt;&lt;img class=&quot;largeIcon float&quot; src=&quot;/adfs/portal/images/idp/idp.png?id=3EADD3E829A20DF612C7A77960FF811E66E3EE6BAE2C33C9B20E7478BAC87548&quot; alt=&quot;Customer or Supplier&quot;&gt;&lt;div class=&quot;idpDescription float&quot;&gt;&lt;span class=&quot;largeTextNoWrap indentNonCollapsible&quot;&gt;Customer or Supplier&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;idp&quot; tabindex=&quot;2&quot; onkeypress=&quot;if (event &amp;amp;&amp;amp; (event.keyCode == 32 || event.keyCode == 13)) HRD.selection('AD AUTHORITY');&quot; onclick=&quot;HRD.selection('AD AUTHORITY'); return false;&quot;&gt;&lt;img class=&quot;largeIcon float&quot; src=&quot;/adfs/portal/images/idp/localsts.png?id=77809433F1EA22C491CA1C7A0836B144BB32E92C12110BF2A2D30810B030734D&quot; alt=&quot;Active Directory&quot;&gt;&lt;div class=&quot;idpDescription float&quot;&gt;&lt;span class=&quot;largeTextNoWrap indentNonCollapsible&quot;&gt;Essendant Associate&lt;/span&gt;&lt;/div&gt;&lt;/div&gt; 
      &lt;/div&gt;
  </code></pre>