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.

Integration with Jenkins and Unix Server using XVFB

HadanMarvHadanMarv Members
edited July 2013 in Sahi - Open Source
Hi,

For a couple of days, we try to integrate Sahi on Jenkins.
Jenkins is installed on an unix debian server. in this case we have to use XVFB to emulate Firefox.
We installed both Xvfb and Firefox as mentionned on the tutorial on your website.
But for the moment we can't run the testrunner. the statuts is failed (FAILURE) and when we start sahi (using start_sahi.sh) we've got this error message :
Reading browser types from: /usr/sahi/userdata/config/browser_types.xml
Firefox was not found at env DISPLAY=:1 firefox

here is the configuration file (as mentionned on tutorial) :
<browserType>
<name>firefox-xvfb</name>
<displayName>Firefox</displayName>
<icon>firefox.png</icon>
<path>env DISPLAY=:1 firefox</path>
<options>-profile "$userDir/browser/ff/profiles/sahi$threadNo" -no-remote</options>
<processName>firefox</processName>
<capacity>5</capacity>
</browserType>

we set env using : export DISPLAY=:1.0 firefox
and start the Xvfb using : Xvfb :1 -screen 0 1152x900x8 &

let us know if we made any mistake on the configuration file.

thanks in advance for your feedback,

Answers

  • narayannarayan Administrators
    Hi HadanMarv,

    Try adding
    <force>true</force>
    
    before
    </browserType>
    
    and check.

    It would look something like this:
    <browserType>
    <name>firefox-xvfb</name>
    <displayName>Firefox</displayName>
    <icon>firefox.png</icon>
    <path>env DISPLAY=:1 firefox</path>
    <options>-profile "$userDir/browser/ff/profiles/sahi$threadNo" -no-remote</options>
    <processName>firefox</processName>
    <capacity>5</capacity>
    <force>true</force>
    </browserType>
    


    Force makes Sahi ignore checking for path.

    Regards,
    Narayan

  • Hi Narayan,

    Great, now we can't see the error message regarding firefox.
    But when we execute the sample script, it always running after 15 minutes.
    We can not see any log file regarding problems or errors.

    Could you tell us what is wrong, of if there is a place to see log file ?

    for information, at the beginning with the other configuration file (without force true), the test fall in error immediatly.

    Regards,
  • I really can't recommend "force=true", Sahi usually recognizes the browser path just fine and if there's an error regarding that path, it can be taken seriously, as far as i know.
    So, it seems legit Sahi can't find "env Firefox" you somehow need to specify a display.

    I usually start sahi in Jenkins with "export DISPLAY=:1 sh sahi.sh". As sahi is starting the browser, firefox should get the right display.
    I just post my confg, you may find it valuable. Its with chromium, but firefox did work as well. And use the default browser_xml :)
    cd $SAHI_HOME/bin
    # path set to bin for some shell script sahi needs to call
    export PATH=$PATH:$SAHI_HOME/bin
    # XVFB_DISPLAY set in Jenkins config
    DISPLAY=$XVFB_DISPLAY sh sahi.sh &
    
    cleanup() {
      lsof -i:9999 -F p | cut -dp  -f2 | xargs kill
      pkill chromium-browse
      pkill Xvfb
      exit 1
    }
    trap "cleanup" 1 2 3 6 15 0
    
    echo "makes sure, Xvfb is running"
    ( test -z "$( pgrep Xvfb )" && ( Xvfb $XVFB_DISPLAY -screen 0 1280x768x24 & ) ) || echo "Xvfb is running"
    
    java -cp $SAHI_HOME/lib/ant-sahi.jar net.sf.sahi.test.TestRunner -test $WORKSPACE/nightlyNoShop.suite -browserType chromium \
    -baseURL http://sahi.example.com/_s_/dyn/Driver_initialized -host localhost -port 9999 -threads 1 -useSingleSession true \
    -initJS " \
    \$jenkinsBuildIndex='$BUILD_NUMBER'; \
    \$jenkinsTimestamp='$BUILD_ID'; \
    \$jenkinsJobName='$JOB_NAME'; \
    \$jenkinsSlave='$NODE_NAME'; \
    " \
    -htmlLog true \
    -htmlLogDir $WORKSPACE/target \
    -junitLog true \
    -junitLogDir  $WORKSPACE/target 
    
    
  • After a long time of browsing google, we find a start of explanation.
    As we can read we have to install iceweasel instead of firefox.
    We continue to investigate to close this installation.
  • I don't get how you come to this IMHO misguided conclusion, but if it works for you, go ahead :)
Sign In or Register to comment.