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 and phantomJs

noizernoizer Members
edited May 2014 in Sahi - Open Source
Hi,
I've installed Sahi under ubuntu 13.10 x64 and it works pretty well. I want to try a load test on a local site so I've installed (from repository) phantomJs. I've followed this: http://sahi.co.in/w/sahi-headless-execution-with-phantomjs
I've created in ~/sahi/extlib/ a file called sahi.js and in browser-type I've putted:
                <browserType>
		<name>phantomjs</name>
		<displayName>PhantomJS</displayName>
		<icon>safari.png</icon>
		<path>/usr/bin/phantomjs</path>
		<options>--proxy=localhost:9999 $userDir/sahi/extlib/sahi.js</options>
		<processName>phantomjs</processName>
		<capacity>5</capacity>
                </browserType>
In sahi.js i've putted:
if (phantom.args.length === 0) {
    console.log('Usage: sahi.js <Sahi Playback Start URL>');
    phantom.exit();
} else {
    var address = phantom.args[0];
    console.log('Loading ' + address);
    var page = new WebPage();
    page.open(address, function(status) {
        if (status === 'success') {
            var title = page.evaluate(function() {
                return document.title;
            });
            console.log('Page title is ' + title);
        } else {
            console.log('FAIL to load the address');
        }
    });
}

when I try to run
sh testrunner.sh ../scripts/myScript.sah http://127.0.0.1/myHost phantomjs
no phantomJs instance is launched. On sahi proxy I can see myScript is running but no browser instace (and no logs written).
Someone can explain me why?

Answers

  • globalwormingglobalworming Moderators
    When starting the Sahi Dashboard, does the phantomJS browser show up as selectable browser?
  • noizernoizer Members
    yes it does|
  • globalwormingglobalworming Moderators
    And when you click the phantomJS button, there should appear the command which is used to start thre browser.. something like:
    /usr/bin/phantomjs --proxy=localhost:9999 $userDir/phantomscript/phantom.js http://sahi.example.com/_s_/dyn/Driver_initialized?browserType=phantomjs
    
    is this correct? And do you see a phantomJS process running? Which phantomJS version are you using?
    phantomjs --version
    
  • noizernoizer Members
    Unforunately, when I clieck any of the browsers buttunos I can't see any output in the console regarding the browser i've selected. I'm launching sahi from the console running dashboard.sh
  • Try phantomjs 1.7 and below. It works for me.
Sign In or Register to comment.