I am new to Selenium and coding. What I am trying to do is click a dynamic link. Here is the scenario.
I have to find a dynamic link in a div that has multiple links.
The link I want to click has the myimage attribute and the link will always be different. There can be N-links in the div and some of the links won't have the myimage attribute.
I can locate the div using XPath, but I am having trouble finding the link I want in the div
In short, I want to look through the li开发者_如何学运维st of dynamic links in a div, find a link that has the myimage class and click it.
Can someone suggest a reference or provide a code snippet on how to do this with Selenium using C#?
I'm assuming that you have the latest version of selenium.
All you need is to extend the XPath you have for the div to include the link with the attribute. I haven't tried this in code but should work:
Selenium.Click("xpath=//a[@class='myimage']")
Check this article for more details
精彩评论