[SOLVED: changed target to //*[contains(@id,“couponAdd”)] ]
I’m adding offers to my Safeway Just4U account.
In the past I successfully used click-//span[contains(text(),‘ADD’)] and I could add however many offers were displayed by adding a click-//span for each offer, for example 4 offers and Kantu would click on each of the 4 “Add” buttons.
Safeway just redesigned their site and now that works, with a hitch: it Adds the first offer, then clicks the same 1st offer, b/c the text “Added” contains Add. 
How do I change the “contains” string so it clicks only “Add” and not “Added”?
Thanks!
Have you tried using verifyText command?
Hi @troydwhite
Try to read this page
https://a9t9.com/kantu/docs/selenium-ide/click
It explains how to recognize web page elements in a relative way.
FAQ: How can I find the n-th link with a specific text?
This question is similar to FAQ: How to find a button with a specific text with XPath? but now we want to get the n-th match, not the first match. There are several good options for this. In the following lets assume the link text is “Download” and we want to click the 6-th link. As test page we use this external page:
- link=Download@POS=6 - this is easy but works for links only
- xpath=(//a[text()=‘Download’])[6] - same as above but in XPath notation
- xpath=(//*[text()[contains(.,‘Download’)]])[6] - this searches for the text in any element and not just links.
An alternative text search that works inside a canvas, image or video is OCR based text search.
Have a nice day
1 Like
Thank you, @newuserkantu
I tried POS but that didn’t work:
[error][ignored] timeout reached when looking for element ‘//span[contains(text(),“ADD”)]@POS=1’
1 Like
Thank you, @Souradeep_Panda
I found verifyText earlier, but it doesn’t seem to be relevant for this situation: Add or Added will always be on the pages I’m running the script on.
I think the issue is “contains”, the ideal command would say “text is Add” and only Add, and would ignore anything else.
1 Like
I looked more closely at the span elements and noticed the “Added” button said “clippedCoupon” and the “Add” button used “couponAdd”. 
I changed the code to //*[contains(@id,“couponAdd”)] and now it only adds new “ADD” items.
I modified this approach: clickAndWait, click - Selenium IDE Commands Tutorial
3 Likes
Hi @troydwhite
Thanks for sharing the solution.
Have a nice day
2 Likes