Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, windows and java based applications. Get your 30 day free trial.

Discuss your Sahi Pro usage patterns, best practices, problems and solutions. Help others solve their problems and seek help from the community when needed. If you need specific support on your application, please email support @ sahipro.com

Insert number into string

RensterUKRensterUK Members
edited November -1 in Sahi - Open Source
All,

Can someone tell me what is wrong here? I've tried all the variants I can think of!

for (var $i=1; $i<6; $i++) {
_click(_link("Change to Custom", _near(_cell("number " + $i + "of 5"))));
}

At run time I just get:
_click(_link("Change to Custom", _near(_cell("number " + 1 + "of 5"))));
_click(_link("Change to Custom", _near(_cell("number " + 2 + "of 5"))));
etc

Whereas of course I am looking for

_click(_link("Change to Custom", _near(_cell("number 1 of 5"))));
_click(_link("Change to Custom", _near(_cell("number 2 of 5"))));
etc

??

Thanks in advance!

Comments

  • narayannarayan Administrators
    Hi,

    What you get is correct, and it would work correctly if you gave a space before "of 5".
    It should be

    _click(_link("Change to Custom", _near(_cell("number " + $i + " of 5")))); // space before of

    Regards,
    Narayan
  • Narayan,

    Sorry, the missing space was just me misquoting. The problem seemingly isnt the space. The problem is that seemingly (at least this is what I see in the controller) - ' "+ $i " ' is being translated as exactly that including the quotes and + signs etc. I just want "number $i of 5" (with $i substituted.
Sign In or Register to comment.