4

How can I automate clicking this anchor tag with Selenium IDE (in Mozilla Firefox of course)?

I tried two different approaches, and neither one worked. Would it matter that this is in a popup window? I can get other controls to work.

HTML (this is an ASP.NET LinkButton control):

<a href="javascript:__doPostBack('EditTestResult$EditOverallTestResults$BucketMove$LBuSelect','')" class="standard-text" id="EditTestResult_EditOverallTestResults_BucketMove_LBuSelect">-></a>

Selenium code that didn't work:

Command: clickAndWait
Target: id=EditTestResult_EditOverallTestResults_BucketMove_LBuSelect
Value: 

Selenium code that didn't work:

Command: clickAndWait
Target: link=->
Value: 
5
  • Yup it matters lot if it were a pop up window, so does this link appear in pop up window?
    – Tarun
    Commented Jul 18, 2011 at 3:55
  • it certainly does. ;-) But the clickAndWait seems to work for other controls in this popup window. Commented Jul 18, 2011 at 5:18
  • are you using Selenium RC or WebDriver?
    – m4tt1mus
    Commented Jul 18, 2011 at 23:19
  • neither right now.. I'm just using the IDE. I have several laboratory workflows I'm trying to get done with the IDE. Then I will start to use JUnit and feed the workflows data in IE, Mozilla, Google Chrome, and Safari using one of those tools. I will learn those tools once I complete the essentials. Commented Jul 19, 2011 at 2:18
  • Try to waitFor an element on the pop up before you do the ClickAndWait action I get the same problem now and then but I usually tackle it like this
    – Theo
    Commented Nov 16, 2011 at 13:25

2 Answers 2

1

Have you tried using an XPath locator?

Try one of these in the Target section of a clickAndWait command:

//a[@class="standard-text"]

//a[contains(@href,"javascript")]

//a[@id="EditTestResult_EditOverallTestResults_BucketMove_LBuSelect"]

You can also prefix each with

xpath=

Example:

xpath=//a[@class="standard-text"]

Check here for more information about the different locators available in Selenium (id, name, dom, xpath, link, css).

2
  • For now, I'll mark this as the answer. I've found that you cannot rely on link text for clicking anchors. I have since switched to using WebDriver and relying on xpath for most my anchor clicks. Commented Mar 13, 2012 at 14:29
  • Great! X-Path can definitely be a lot more flexible! Commented Mar 14, 2012 at 15:26
0

So if button is on a pop up window then you would first have to bring control on pop window with some thing like -

selenium.click("elementLocator");
selenium.waitForPopupWindow("windowID" , "waitPeriod"); 

// I have seen window 
// title also working hence you could try that also

selenium.focus("windowID")

// Continue with operations on Pop up window
// Bring control back on main window

selenium.focus("")

// Continue with operations on main window
1
  • I think I may have brought this on a tangent when I mentioned the popup window. The popup isn't the issue. Because these controls are in the popup. My problem is simply clicking that LinkButton (anchor tag) .. it just doesn't click it. I'll see if i can replicate it and post an example soon. Commented Jul 19, 2011 at 5:47

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.