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.

Sahi Playback Giving Me Nullpointer Exception !!! Please Help

desicheledesichele Members
edited November -1 in Sahi - Open Source
I tried to use the playback method, all the steps are recorded in the scripts but when i tried to play it back, It gives me the following error..Can anybody please help me...i am really trying to use the comprehensive features of Sahi, which looks very promising to me..thank you

java.lang.NullPointerException
at net.sf.sahi.command.Player.stop(Player.java:55)
at net.sf.sahi.command.Player.stop(Player.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sf.sahi.command.CommandExecuter.execute(CommandExecuter.java:53)
at net.sf.sahi.LocalRequestProcessor.getLocalResponse(LocalRequestProces
sor.java:42)
at net.sf.sahi.ProxyProcessor.processLocally(ProxyProcessor.java:199)
at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:71)
at java.lang.Thread.run(Unknown Source)

Comments

  • narayannarayan Administrators
    Try a simpler smaller script on some simple site and check if it fails. If it does, send the script too. Also check on a different browser and see.
  • Tried again a simple file to record a few steps : Record -> Search in Google -> Stop
    Script Below:

    _setValue(_textbox("q"), "google");
    _click(_submit("Google Search"));

    but same thing..when i try to play it back..command promt gives me a null pointer exception and sahi controller says : Success - Stop Playback
  • Have you looked at the script log?

    In the "Playback" tab, click the "View Logs" link.

    Click the link for the log of the test run with errors. See any red line items in there?
  • ooh..I figured it out...i didn't set the start page initially..its working fine now..but i have two more questions..

    1. What the usage of "Assert" in the recording controller .. i mean .. i could have just clicked on specific link or buttons i need
    2. Can i use any high level instruction..for example -> using loop or inherit/import/use scripts (to overcome rewriting) or compare function (regular expression) within the scripts..

    Please Let me know
  • Hmmm... Need to add some logic to notify parameters are missing.

    1. You can use "Assert" to make sure expected text, buttons, <divs>, <spans>, images, etc... are there on the page.

    a. With the Sahi Controller open, hold down the "CTRL" key and mouseover an element like an image or a link or something.
    b. Notice how the "Accessor:" and "Alternative:" fields get populated
    c. Click the "Test" button. The assert statements are evaluated and you get a response stating either "true" or "false".
    d. Click "Append to Script" to have the asserts added to the script you are recording.

    2. Yes. All of them.

    a. Loops: http://sahi.co.in/w/Script/
    b. Inherit/import/use: http://sahi.co.in/w/_include
    c. RegEx: Use the JavaScript object -> http://www.w3schools.com/js/js_obj_regexp.asp
  • desicheledesichele Members
    edited July 2008
    I really liked the _include function...but couldn't use it for some reason..

    error: THIS IS THE ERROR SAHI Log PROVIDED ME

    Error loading script. Firefox may point to the exact line. ReferenceError: _include is not defined() with some js error which i couldnt post * New Members can not post links, images or email addresses until they become more active.

    ALL I TRIED TO DO IS VERY SIMPLE

    testLogin.sah ->
    _include("adminLogin.sah");
    login_admin("username");
    adminLogin.sah ->
    function login_admin($username)
    {
    _setValue(_textbox("username"),$username);
    _click(_submit("Login"));
    _click(_link("Orgs"));
    }

    Both the files are in the same directory..and i even tried with file path ( _include($filepath)); where $filepath contained the absolute location of the file but its the same issue... _inlude is not defined ...

    Thanks for all of the valuable inputs from StringyLow and Narayan...It really helping me guyz
  • Another thing is..One of my webpages doesnt have button..so only option to submit the form is to press "Enter" Key...which Sahi doesnt seem to be recording...any idea !!!!..its a form which type is get and it gets submitted when Enter key is pressed.
  • Hi,

    Try giving the absolute path in the _include() statement itself. We can have some more idea about the error if could view the entire error log.
    And for the second problem Try using the _keyPress() function. The key code for ENTER is 13 if i am not wrong. But Narayan can throw some more light on how to use the key code directly in the _keyPress() function as i tried that but in vain.

    Regards,
    Pankaj.
  • DonnaMooresDonnaMoores Members
    edited July 2008
    I too am experiencign problems like this.

    I have installed Sahi / Java onto a second machine in my work place, and on my home PC.

    Sahi installed and ran brilliantly on my home PC and on my first installation.

    However on my second installation I am experiencing a problem where
    java.lang.NullPointerException
    at net.sf.sahi.command.Player.stop(Player.java:55)
    at net.sf.sahi.command.Player.stop(Player.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.sf.sahi.command.CommandExecuter.execute(CommandExecuter.java:53)
    at net.sf.sahi.LocalRequestProcessor.getLocalResponse(LocalRequestProces
    sor.java:42)
    at net.sf.sahi.ProxyProcessor.processLocally(ProxyProcessor.java:199)
    at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:71)
    at java.lang.Thread.run(Unknown Source)
    It just doesn't appear to be setting the start page correctly. If in the Sahi controller, on the playback tab I select my file, hit the set button, and then try and view the parsed file, it displays the message
    "No Script has been set for playback."
    Do you have any suggestions.
  • I couldnt get _keyPress() to work !!
    all i had to do is create the event as ENTER key is pressed..HTML element is form and i tried the code below:
    _keyPress(document.form,'ENTER'); //as its only one key to be pressed

    HTML looks like this :
    <form method='get' action='SU.pm'>
    Enter the username below then hit enter:
    <br/>
    <br/>
    <input type='text' name='username' value=''/>
    </form>

    can anybody suggest me something to resolve the issue..please..thank you
  • rksrks Members
    looking at the _keyPress() method in concat.js, it will try to generate a key press event for the first character in case the parameter passed to the method is a string. Try passing the numeric character code, i.e. 13.
Sign In or Register to comment.