Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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: 
share|improve this question
    
Yup it matters lot if it were a pop up window, so does this link appear in pop up window? –  Tarun Jul 18 '11 at 3:55
    
it certainly does. ;-) But the clickAndWait seems to work for other controls in this popup window. –  MacGyver Jul 18 '11 at 5:18
    
are you using Selenium RC or WebDriver? –  m4tt1mus Jul 18 '11 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. –  MacGyver Jul 19 '11 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 Nov 16 '11 at 13:25
add comment

2 Answers 2

up vote 0 down vote accepted

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).

share|improve this answer
    
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. –  MacGyver Mar 13 '12 at 14:29
    
Great! X-Path can definitely be a lot more flexible! –  rishimaharaj Mar 14 '12 at 15:26
add comment

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
share|improve this answer
    
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. –  MacGyver Jul 19 '11 at 5:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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