КОИНС.Студия - Статьи - Инсталляция и настройка программ - selenium

selenium

  • Create a user for selenium:
    adduser selenium

  • Install X virtual framebuffer:
    yum install Xvfb

  •  
  • Create autoload script in /etc/init.d/xvfb
    #!/bin/bash
    #
    # /etc/rc.d/init.d/xvfb
    #
    # chkconfig: 345 95 28
    # description: Starts/Stops X Virtual Framebuffer server
    # processname: Xvfb
    #

    . /etc/init.d/functions

    [ "${NETWORKING}" = "no" ] && exit 0

    PROG="Xvfb"
    PROG_OPTIONS=":7 -screen 0 1024x768x24 -extension RANDR"
    PROG_OUTPUT="/var/log/xvfb.log"
    PROG_USER="selenium"

    case "$1" in
        start)
            echo -n "Starting : X Virtual Frame Buffer "
            daemon --user $PROG_USER $PROG $PROG_OPTIONS >$PROG_OUTPUT 2>$PROG_OUTPUT &
    #        disown -ar
    #        /bin/usleep 500000
    #        status Xvfb >/dev/null && echo_success || echo_failure
            RETVAL=$?

            if [ $RETVAL -eq 0 ]; then
                /bin/touch /var/lock/subsys/Xvfb
    #            /sbin/pidof -o  %PPID -x Xvfb > /var/run/Xvfb.pid
            fi
            echo
            ;;
        stop)
            echo -n "Shutting down : X Virtual Frame Buffer"
            killproc $PROG
            RETVAL=$?
            [ $RETVAL -eq 0 ] && /bin/rm -f /var/lock/subsys/Xvfb /var/run/Xvfb.pid
            echo
            ;;
        restart|reload)
            $0 stop
            $0 start
            RETVAL=$?
            ;;
        status)
            status Xvfb
            RETVAL=$?
            ;;
        *)
         echo $"Usage: $0 (start|stop|restart|reload|status)"
         exit 1
    esac

    exit $RETVAL
  • Add Xvfb to autoload:
    chmod +x /etc/init.d/xvfb
    chkconfig xvfb on
    service xvfb start

  • Install selenium server:
    mkdir /usr/local/lib/selenium
    cd /usr/local/lib/selenium
    wget http://selenium.googlecode.com/files/selenium-server-standalone-2.4.0.jar
    chmod a+r selenium-server-standalone-2.4.0.jar
    mkdir -p /var/log/selenium/
    chown selenium:selenium /var/log/selenium
    chmod g+w /var/log/selenium

  • Create autoload script for selenium:
    #!/bin/bash
    #
    # /etc/rc.d/init.d/selenium
    #
    # chkconfig: 345 96 28
    # description: Starts/Stops Selenium server
    # processname: Selenium
    #

    . /etc/rc.d/init.d/functions

    PROG_EXEC="/usr/local/lib/selenium/selenium.sh"
    PROG_USER="selenium"
    PROG_NAME="selenium"
    PROG_PID="/tmp/selenium.pid"
    PROG_LOG="/var/log/selenium/selenium.log"
    LOCK_FILE="/var/lock/subsys/$PROG_NAME"

    start() {
      echo -n "Starting Selenium Server:"
      if [ -s $PROG_PID ]; then
        RETVAL=1
        echo -n " Already running." && warning
        echo
      else
        runuser -u $PROG_USER $PROG_EXEC | {
          read -r PID RET
          RETVAL=$RET
          [ $RETVAL -eq 0 ] && touch $LOCK_FILE && success || failure
          echo
          echo $PID >$PROG_PID
        }
      fi
    }

    stop() {
      echo -n $"Stopping $PROG_NAME:"
      killproc -p $PROG_PID
      retval=$?
      echo
      [ $retval -eq 0 ] && rm -f $LOCK_FILE
      return $retval
    }

    selenium_status() {
      curl http://localhost:4444/wd/hub/status >/dev/null 2>/dev/null
      RETVAL=$?
      if [ $RETVAL -eq 0 ]; then
        echo "Selenium server is running."
      else
        echo "Selenium server is stopped.";
      fi
    }

    case "$1" in
        'start')
           start
        ;;
        'stop')
           stop
        ;;
        'restart')
           stop
           start
        ;;
        'status')
          selenium_status
        ;;
    esac
  • Add it to autoload, and start:
    chmod +x /etc/init.d/selenium
    chkconfig selenium on
    service selenium start

  • Add a list of all hosts to /etc/hosts:
      127.0.0.1 t211.wellnessliving.local
      127.0.0.1 t212.wellnessliving.local
      127.0.0.1 t221.wellnessliving.local
      127.0.0.1 t222.wellnessliving.local
      127.0.0.1 t231.wellnessliving.local
      127.0.0.1 t232.wellnessliving.local
  • Install firefox:
    yum install firefox

  • Create global selenium directory:
    mkdir /home/selenium/global
    chown selenium:apache /home/selenium/global
    chmod g+rwx /home/selenium/global

Additional resources

Последняя модификация: 14.06.15 21:12