0

Need a resource not Selenium documentation or W3C website, all there is information about Java, Python codes. I need to see how to use FindElement(By) in VBA or

.FindElementByCss("li > div  > a=[href]").Click

The most useful site with examples I found is https://endtest.io/guides/blog/2020/07/31/a-practical-guide-for-finding-elements-with-selenium/

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
xlmaster
  • 659
  • 7
  • 23

1 Answers1

1

You were close enough. As an example for the following HTML:

<li>
    <div>
        <a href="https://stackoverflow.com">Stack Overflow</a>
    </div>
</li>

To identify the desired element you can use either of the following locator strategies:

  • Using FindElementByCss:

    .FindElementByCss("li > div > a[href]")
    
  • Using FindElementByCss (canonically):

    .FindElementByCss("li > div > a[href*='stackoverflow']")
    
  • Using FindElementByXPath (canonically):

    .FindElementByXPath("//li/div/a[@href=\"https://stackoverflow.com\"]")
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I found the reason why, it is not clickable. View...When scrolling down the screen, it clicks easily. I will open new question thread – xlmaster Aug 21 '22 at 11:52