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

facing Error while trying to retrieve some data from popup window!!!!

Akss004Akss004 Members
edited November -1 in Sahi - Open Source
Hi Narayan,

I am facing some issue while dealing with popup window. I am able to click on button and enter value in text box of popup window.

but when i am trying to use some _exists,_isvisible or _getText kind of function to verify some data or retrieve some data from pop up window.

Execution is getting failed and sahi log file giving error like
"JSERROR
TypeError: Cannot call method "_getText" of undefined"

Some portion of my script which is getting failed is as below.

"
_click(_popup("DailyPunchEntries")._button("Edit Punches"));

var $temp = _popup("LongJump")._getText(_textbox("PunchNote"));

"

take a note that i am able to set the value of _textbox("PunchNote")....but can not retrive it. And also if i copy paste same in sahi controler and "TEST" it from there its working fine. but problem occurs while executing this two lines as script.

Can you please take a look at this ??

Suggest me if is there any work around this issue and also if i m doing something wrong with above code....

Comments

  • narayannarayan Administrators
    You can do it in 2 ways:
    _selectWindow("LongJump"); // from now on all actions will occur on popup window
    var $temp = _getText(_textbox("PunchNote"));
    _selectWindow(); // back to base window
    


    or
    var $temp;
    _popup("LongJump")._set($temp, _getText(_textbox("PunchNote")));
    

    Regards,
    Narayan
  • Hi narayan,

    Thanx for you quick help this things has worked here in my case And problem has been solved.

    One more thing i would like to ask that this command you have suggested "_selectWindow();" is not found on SAHI 's website.

    "http://sahi.co.in/w/sahi"

    Can i know is there any other wiki kind of thing exist for SAHI command?
    Cause that will help me and other users a lot if they found such all command at one place.
  • narayannarayan Administrators
    Hi Akash,

    We sometimes release some APIs but wait for feedback from selective users before we disclose them publicly. _selectWindow has been recently added. We will be updating the online docs soon.

    Regards,
    Narayan
  • JyotinJyotin Members
    hey....Akash.. can u help me out by telling me how were you able to fill the textbx's value in popup window... also script for clicking button than?
  • Yes...Jyotin...

    you can use feature suggested by Narayan in above post.

    for e.g.

    _selectWindow("PopUp window name");

    .
    .
    .

    _selectWindow();


    in between this two command you can write your normal sahi command(without adding 'PopUp()' prefix) to fill the textbox of popup window.....or get some text from the same.


    for e.g.


    _selectWindow("PopUp window name");

    _getText(_textbox("BoxName"));

    _selectWindow();


    now this _textbox("BoxName" ) is on popup window but after using above

    _selectWindow("PopUp window name");

    command you can use this command as you perform in normal window or browser.
Sign In or Register to comment.