6

I'm using Selenium's IDE in FireFox to do some testing, and I want Selenium to click the second link (Text2). Any idea how I do that? Unfortunately I don't have access to the HTML and can't modify it. The record function doesn't seem to register the click.

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>
1
  • You have Text1 twice in your example... Commented Jul 3, 2012 at 13:45

3 Answers 3

4

Selenium supports the link=Link Text locator as well. 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.)

Sign up to request clarification or add additional context in comments.

2 Comments

@Roddy - in that Link Text what should be given? <a title="Logout" href="/base/base/base.en"> So i should give logout in Link Text?
@EmmanuelAngelo.R Let's say you have <a href="/logout">Click to Logout</a>. Then your link text is Click to Logout.
1

You Can Try

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


Looking for same or anything else?

8 Comments

It didn't work - I'm afraid I'm woefully unfamiliar with Xpath. What exactly is that doing?
it will find text2 in tag a, and you can click on that text then.
[error] locator not found: //a[contains(text(),'View Previous Statements')] Where View Previous Statements = text2
//a[contains(text(),'View Previous Statements'] try this 1
Same error, unfortunately. :( [error] locator not found: //a[contains(text(),'View Previous Statements']
|
1

Please disregard this post. Selenium is ignoring the "Value" field and simply selecting the 1st occurrence of span.class3. Sorry about this. I should have tested more before posting.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.