Selenium click on the link

I am using the Selenium IDE in FireFox to do some testing, and I want Selenium to click the second link (Text2). Any idea how I do this? Unfortunately, I do not have access to HTML and cannot change it. The recording function does not seem to register clicks.

The code is attached below. Thanks in advance!

<div class="class1"> <div class="class2"> <span class="class3"><a href="#" onclick="fn1();">Text1</a></span> </div> </div> <div class="class1"> <div class="class2"> <span class="class3"><a href="#" onclick="fn2();">Text2</a></span> </div> </div> 
+6
source share
3 answers

Selenium supports the link=Link Text locator. If you know the exact link text, you can use this locator, but not otherwise. So, for your examples above: link=text2 or link=View Previous Statements . (See this site and this site for other locators.)

+4
source

You may try

 //a[contains(text(),'text2')] OR //span/a[contains(text(),'text2')] 


Looking for the same or something else?

+1
source

Please ignore this post. Selen ignores the Value field and simply selects the first occurrence of span.class3. Sorry about that. I should have tested more before posting.

Original post: I have a similar web page and I was able to use the following Selenium IDE command: command: clickAndWait target: css = span.class3 value: Text1

+1
source

Source: https://habr.com/ru/post/919583/


All Articles