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.

Upgrading to version 2

DonnaMooresDonnaMoores Members
edited November -1 in Sahi - Open Source
I am looking into upgrading to version 2 of Sahi

My code currently looks like this:
function getTextbox($control)
{
    return _textbox($control).value;
}

function assertTextbox($popup, $control, $value, $space)
{
    if ($popup == null)
    {
        _assertNotNull(getTextbox($control));
        if ($space == null)
        {
            _assertEqual(trimITL($value, true), getTextbox($control));
        }
        else
        {
            _assertEqual($value, getTextbox($control));
        }
    }
    else
    {
        _popup($popup)._assertNotNull(getTextbox($control));
        if ($space == null)
        {
            _popup($popup)._assertEqual(trimITL($value, true), getTextbox($control));
        }
        else
        {
            _popup($popup)._assertEqual($value, getTextbox($control));
        }    
    }
I think I need to wrap the browser tags around my getTextbox function.

My question is where does the _popup go. Does it go in the getTextbox function, and if so how. I am a little confused

Many thanks
Donna

Comments

  • Hi Donna,

    From the code above it appears that only the function getTextbox() is acting on the page's DOM. So I think only this function would need to be wrapped in the <browser> tag. Rest of the code should go as is. Lets discuss whereever you face problem in the code.

    Regards,
    Pankaj.
  • narayannarayan Administrators
    Pankaj, you missed trimITL.
    Donna you need to have the functions trimITL and getTextbox in <browser> tags.

    If you are confused, have a look at the parsed script.
    In V2 the script is executed on the proxy.
    _assertNotNull(getTextbox($control)) 
    will get converted to 
    _sahi.schedule("_sahi._assertNotNull(getTextbox("+$control+"));", debugInfo);
    
    _sahi.schedule(command, debugInfo) will send the command to the browser. The browser will then eval it. So if you see your functions being a part of the command string, make sure that those functions are available on the browser by defining them within <browser> tags.

    If you want a function to be executed on the popup, just call it like _popup("id")._click(myCustomFinder());
    _popup should ideally never be used inside a browser function.
  • Oops!
    Thanks Narayan for the correction :)
  • Thank you for your help. I am going to be giving it a try later today.
Sign In or Register to comment.