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 do I get the base URL passed to Sahi

hari19hari19 Members
edited November -1 in Sahi - Open Source
How do I get the Base URL passed to Sahi in my scripts ?
Also I have a test suite with the following contents
script1.sah /myApp
script2.sah /myApp2

How do I get the URIs passed in the test suite ( /myApp , myApp2 ) ?
Tagged:

Comments

  • narayannarayan Administrators
    I did not understand your question! You set the baseURL as a parameter to TestRunner via the batch file/shell script or ant script. Sahi resolves /myApp in relation to that baseURL and navigates to that URL. You can access the URL of a page at anytime via

    _set($url, document.location.href);

    Let me know if you are looking for something else.
  • hari19hari19 Members
    edited July 2009
    Yeah , I'm looking for something else.
    If suppose my base URL is http://host:port/myApp and it redirects to http://host:port/myApp/index.html or http://host:port/myApp/login.html
    _set($url, document.location.href); will return http://host:port/myApp/login.html and not http://host:port/myApp which is what I want.

    What I want to do is get baseURL ( http://host:port/myApp ) and then _navigateTo a different URL.
    var $baseURL = _getBaseURL();
    var $urlForSomething = $baseURL+"/something";
    _navigateTo($urlForSomething)
    

    I may also need to check if the content of the resultant page has "$baseURL".

    I guess this is something that Sahi will have to provide a function for.
  • narayannarayan Administrators
    Makes sense. Right now use the url and substring it as needed in a browser function. I will add it to a coming release.
  • i got errot when i used _getBaseURL()
    ReferenceError: "_getBaseURL" is not defined.
  • narayannarayan Administrators
    Hi Paresh,

    Please do not open old threads. Please open a new one, explain what you are doing and why you are doing it.

    Regards,
    Narayan
  • Actually i do not know it's already added

    why i m doing this because i want to store log with baseurl name for my custom log report

    ./testrunner.sh test.suite http://10.10.10.10 firefox

    function _getIpFrombaseUrl()
    {
    _set($url, document.location.href);


    var $str = $url.split('//');
    var $str1 = $str[1].split('/');
    return $str1[0];
    }
    $GetBaseURL=_getIpFrombaseUrl()

    u can get 10.10.10.10
    and you set your log file name with 10.10.10.10.log

    it's helpful when if any one run multiple test.suite with different base Url in one system.
    you can easily distinguish log file with base Url
Sign In or Register to comment.