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 can I create regular expression to satisfy the stated condition in my summary?

How can I create regular expression to satisfy the following:

1. _click(_button("btn"));
2. _click(_button("btn[0]"));
3. _click(_button("btn[1]"));
4. _click(_button("btn[n]"));

Best Answer

Answers

  • I tried but error message "SyntaxError: Unexpected string" occur
  • I tried but error message "SyntaxError: Unexpected string" occur
  • Try using a for loop:

    for (var $i=0;$i<=n;$i++){
    _click(_button("btn["+$i+"]"));
    }

    If there are multiple buttons on the screen with the same id/name, the first DOM object of that button will be _button("btn[0]"), _button("btn") would only apply if it was the only DOM object of that name.
  • Try using a for loop:

    for (var $i=0;$i<=n;$i++){
    _click(_button("btn["+$i+"]"));
    }

    If there are multiple buttons on the screen with the same id/name, the first DOM object of that button will be _button("btn[0]"), _button("btn") would only apply if it was the only DOM object of that name.
  • Try using a for loop:

    for (var $i=0;$i<=n;$i++){
    _click(_button("btn["+$i+"]"));
    }

    If there are multiple buttons on the screen with the same id/name, the first DOM object of that button will be _button("btn[0]"), _button("btn") would only apply if it was the only DOM object of that name.
Sign In or Register to comment.