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.

Dynamic Link

KMANDOKMANDO Members
edited November -1 in Sahi - Open Source
Hi,

I was wondeirng if anyone knew if wildcards could be possible to use with links


example:
_click(_link("Electronic[2]"));


now sine the numeric values change everytime theres a new build by the framework would it just be as easy as placing a " * " after "Electronic*" ?

whats the best sollution to this problem ?


thanks

Comments

  • Use _click(_link(/Electronic/));
  • thanks pankaj.nith ,

    I'll try this one out !
  • KMANDOKMANDO Members
    edited December 2008
    So before when using the sahi controller to get the accessor sahi said it was:


    _button("Save[1]")


    second build we got the accessor tells me that the same object is now identified as:

    _submit("Save")



    now this seems to be greatly difficult to solve since not just the name of the object is being changed but also the object's identification ?


    our framework assigns id's upon building, so I'm not sure what to do ???


    what could be done?
  • narayannarayan Administrators
    I think, there seems to have been a change in your application code, in which they changed a button to a submit button. I don't think you will encounter this problem again and again.
  • Hi!

    I have the same problem, but not for a link object, for a select object. I try with " / ", but is not working =(

    The code that i try is:
    _setSelected(_select(/cb_/), "Option")
    instead of
    _setSelected(_select("cb_12345"), "Option")

    There is a way to handle that?

    Thanks
  • narayannarayan Administrators
    Checking ...
  • MagUiMagUi Members
    Anything yet?? :(
  • narayannarayan Administrators
    Oh sorry! That thing works well for me.
    Put _highlight(_select(/cb_/)) in the Evaluate Expression box (in the recorder), click Test--> and see what you get.
  • KMANDOKMANDO Members
    edited March 2009
    HEy If anyone wanted to know about this issue, seems to have been mine as I had tried to run the same .sah script in a different browser window than it was recorded in. This could be a bug as I recorded in firefox 2 then tried to run them in IE 7.

    Each browser had its own way of identifying the object thus playing back would fail in one.

    and I'm only speaking about the _button() and _submit()


    as for the [1] . this was set because of our builds.



    _button("Save[1]")

    _submit("Save")
  • narayannarayan Administrators
    KMANDO,
    Could you please confirm that, the same element is being identified as _button("Save") and _submit("Save") on different browsers?
    I see this as a major bug because it prevents such a script from being reused, and needs to be fixed ASAP.
    Regards,
    Narayan
  • MagUiMagUi Members
    narayan wrote:
    Oh sorry! That thing works well for me.
    Put _highlight(_select(/cb_/)) in the Evaluate Expression box (in the recorder), click Test--> and see what you get.
    Thanks narayan!

    After trying what you said, I just realice that my real problem is that there is other object named "cb_field", so, when I do: _setSelected(_select(/cb_/), "Option") , is trying to select the option on the other object, and dont find it.

    Do you think that I must create a new post explaining that problem? So, maybe, someone can help me on figure out how can I reference to the object that I want...

    Thanks!
  • Hi,

    Try using index in that case.
    eg. _setSelected(_select(/cb_[1]/), "Option"); or _setSelected(_select(/cb_[2]/), "Option");
    to see if it works.
    You will need to identify the index by hit and trial.

    Regards,
    Pankaj
  • MagUiMagUi Members
    Hi Pankaj, I try what you said, but is not working :(

    If I set: _setSelected(_select(/cb_[1]/), "Option"); only works if the object is named as "cb_1xxxx".
    Seems like:
    _setSelected(_select(/cb_[1]/), "Option");
    works the same than:
    _setSelected(_select(/cb_1/), "Option");

    There is a way to identify the object by any other property?

    Thanks,
    MagUi
  • narayannarayan Administrators
    MagUi,
    When you mouseover that element, what does the "Alternative:" show? Paste that here and we can find an easy way to get to it.
    -Narayan
  • MagUiMagUi Members
    I already take a look to the alternative, but I think that is not helpful, because is named as the same way :/

    See:

    Accesor: _select("cb_22312")
    Alternative: top.frames[0].document.getElementById('cb_22312')

    The other object is always named as _select("cb_field") - alternative: top.frames[0].document.getElementById('cb_field') -

    There is a way to avoid select nothing from a specific object (in this case from " _select("cb_field") ") and search for the next object that satisfies the condition of _select(/cb_/) ?

    MagUi
  • narayannarayan Administrators
    This case is fairly easy. Just use _select(/cb_\d/) instead of _select(/cb_/).
    We are basically matching cb_<digit> so that cb_field does not get selected.
  • MagUiMagUi Members
    Thanks narayan!! Now is working! :D

    Thanks all! :)

    MagUi
Sign In or Register to comment.