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.

If\esle conditions from external file

Art1kArt1k Members
edited August 2014 in Sahi Pro
Hi,

I need a script that chooses the correct domain for tests before it opens the site. Before my attempt to make universal dmn file it worked gr8 but else\ if now give error: "Error in script: syntax error" on line with "else"

So i have problem with if\esle - i get syntax error on this script:

function domain($site, $link) {
var $link
var $site
if($site == "to");{
$link = "http://qa.+$site+.com/";
}
else
{
$link = "http://+$site+.stable.dev.com/";
}
_navigateTo($link);
}

//Set domain for widgets
function widgets($site, $widgets) {
var $widgets = "widgets."+$site+".az-qa.com/";
_selectDomain($widgets);
}


Included File:

//Scripts that generate e-mail address and choose our testing environment
_include("email.sah")
_include("Domain_bin.sah")


var $dmn = "to"; // Function need to be set depending on our env

domain($dmn);
widgets($dmn);

_setValue(_textbox("registration_first_name"), "Test");

Answers

  • Art1kArt1k Members
    Solved it now this works:

    function domain($site, $link) {
    var $link
    var $site
    if($site == "to"){
    $link = "http://qa.+$site+.com/";
    }
    else
    {
    $link = "http://+$site+.dev.com/";
    }
    _navigateTo($link);
    }

    //Set domain for widgets
    function widgets($site, $widgets) {
    var $widgets = "widgets."+$site+".az-qa.com/";
    _selectDomain($widgets);
    }

    But i get: _navigateTo("http://qa.+$site+.com/";) How i can insert that variable into the link? It gives the right condition result but doesn't insert the variable
  • Can u try _call(window.open($link))
  • Art1kArt1k Members
    edited October 2014
    if ($env.indexOf("qa") > -1){ // QA
    $link = "http://"; +$site+ "." +$env+ ".rnd.com";

    Solved
Sign In or Register to comment.