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 can I use htmlunit with sahi?

gligogligo Members
edited November -1 in Sahi - Open Source
I am a little bit confused....can you help me, how can I run sahi tests with htmlunit....?

Comments

  • gligogligo Members
    So...is that means that there is no way or just, that nobody use the combination?
    or just that my question seems stupid....I dont understand anyway...
  • narayannarayan Administrators
    Hi Gligo,

    If you are looking for a headless browser, you can use PhantomJS which is based on WebKit. Detailed instructions are here: http://sahi.co.in/w/sahi-headless-execution-with-phantomjs

    Regards,
    Narayan
  • narayannarayan Administrators
    Here is a older post on using HTMLUnit. http://sahi.co.in/forums/viewtopic.php?id=706
    We will be providing better docs on that soon.

    Regards,
    Narayan
  • gligogligo Members
    THANK you Narayan!
    I tried with phantom, but what I get is the well-known message: Script did not start within 150 sec

    and exception:

    16.05.2011 10:56:52 net.sf.sahi.test.ProcessHelper kill
    INFO: Kill: null
    java.lang.NullPointerException
    at net.sf.sahi.test.ProcessHelper.killPIDs(ProcessHelper.java:172)
    at net.sf.sahi.test.ProcessHelper.kill(ProcessHelper.java:165)
    at net.sf.sahi.test.BrowserLauncher.kill(BrowserLauncher.java:89)
    at net.sf.sahi.test.TestLauncher.kill(TestLauncher.java:130)
    at net.sf.sahi.test.SahiTestSuite.notifyComplete2(SahiTestSuite.java:182
    )
    at net.sf.sahi.test.SahiTestSuite.notifyComplete(SahiTestSuite.java:171)

    at net.sf.sahi.rhino.RhinoScriptRunner.stop(RhinoScriptRunner.java:259)
    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 org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:24
    7)
    at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:333
    0)
    at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487)
    at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.j
    ava:164)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3
    98)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:306
    5)
    at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.j
    ava:175)
    at org.mozilla.javascript.Context.evaluateString(Context.java:1104)
    at net.sf.sahi.rhino.RhinoScriptRunner.run(RhinoScriptRunner.java:149)
    at java.lang.Thread.run(Unknown Source)






    Can you advise me something?
  • narayannarayan Administrators
    Hi Gligo,

    There was a problem in the documentation on http://sahi.co.in/w/sahi-headless-execution-with-phantomjs

    === was rendered as = due to some rendering problem in our CMS (if this intrigues you, we are using textile as the templating engine and == is a shortcut for raw formatting)

    Please take the new sahi.js code from the above link to make your playback work.

    Regards,
    Narayan
  • gligogligo Members
    Thank you! It works. But I have another problem.
    Is there such a thing for Phantomjs as it is for the other browsers to check what kind of browser is running?
    Something like:
    _isIE();
  • narayannarayan Administrators
    Good point! Not yet.

    You can check like this
    if (_condition(window.phantom != null)){
       _debug("This is phantom!")
    }
    
  • gligogligo Members
    Yes, works :)
    But...another question then...
    Is it possible with this headless browser each sahi function to be executed?
    I mean, something like that:
    $row = _getCellText(_div("/x-grid3-col-row-number-id/",_near(_div("/AutoTDate/"))));
    gives me an error

    Logging exception:
    _sahi.setServerVar('___lastValue___1305615491238', _getCellText(_div("/x-grid3-col-row-number-id/", _near(_div("/AutoTDate/")))));
    TypeError: Result of expression 'el' [undefined] is not an object.
    No trace available

    But with the other borwsers this thing works...
  • gligogligo Members
    Hi Narayan,
    have you any information about this above?
    I need really to know this....
    thank you!
  • gligogligo Members
    Anyone to know the answer or to have decision of my problem?
    I have lot of functions with paramters and it seems that phantom has problems with that....
    The pure sahi functions are execute dwithout problems...
Sign In or Register to comment.