18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

How to capture a dynamic link with a common text

rajeevanandrajeevanand Members
edited November -1 in Sahi - Open Source
Hi

How can I capture and click on a link dynamically created.

For example:

I add some websites and their URLs into the DB

Yahoo - httpCOLONSLASHSLASHwwwDOTyahooDOTcom
Google -httpCOLONSLASHSLASHwwwDOTgoogleDOTcom
Sahi - httpCOLONSLASHSLASHwwwDOTsahiDOTcoDOTin

(Sorry, I had to use COLON, SLASH, DOT as I was not allowed to put in a proper URL)

The URLs here are examples, but they would actually be in php code something like
assignURLtoSite?siteID=2
and linked to HYPERLINK (please see all links will appear as HYPERLINK)

When displaying the same on my page, it's displayed as

Website Name Link
Yahoo HYPERLINK
Google HYPERLINK
Sahi HYPERLINK

So, I need to assert that Yahoo or Google exists on the page and click the corresponding HYPERLINK in that line.

How can I do this ?

Thanks in advance for your help.

Rajeev

Comments

  • narayannarayan Administrators
    Hi Rajeev,

    If these are in a table, you can assert Yahoo with

    _assertExists(_cell("Yahoo"))


    To click the hyperlink near Yahoo, use

    _click(_link(0, _near(_cell("Yahoo"))));

    Hope that helps,
    Regards,
    Narayan
  • Hi Narayan

    Thanks for your prompt response.

    That was really useful. It works beautifully.

    Cheers
    Rajeev
This discussion has been closed.