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/
CodePudding user response:
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\"]")