Coder Social home page Coder Social logo

gitpocket / selenium-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ninjix/selenium-server

0.0 1.0 0.0 156 KB

Scripts and files related to setting up a headless Selenium server

License: GNU General Public License v2.0

Shell 93.81% Python 6.19%

selenium-server's Introduction

Selenium Server

Selenium is an automated web application testing system. This set of scripts, files and instructions provide the tools necessary to setup a headless test server on CentOS 6.5 server. All browser tests are performed using the Xvfb display server.

Installation

Make yourself root.

sudo bash

Install the IUS Community Project repo

rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm
yum -y update

Install required packages.

yum -y install firefox Xvfb libXfont Xorg jre

Create a user account named selenium to run the services.

useradd selenium

Create a directory where Selenium will live.

mkdir -p /opt/selenium

Download the latest version of the Selenium

cd /opt/selenium
wget http://selenium-release.storage.googleapis.com/2.43/selenium-server-standalone-2.43.1.jar

Copy the init scripts to the /etc/init.d directory.

cp centos/initd/* /etc/init.d/

Set the Selenium and Xvfb daemons to start on boot.

chkconfig --add seleniumd
chkconfig --add xvfbd
chkconfig seleniumd on
chkconfig xvfbd on

Start the services.

service seleniumd start
service xvfbd start

Setup Log Rotation

Copy the logrotate configuration files to the /etc/logroate.d directory.

cp centos/logrotate.d/* /etc/logrotate.d/

Firewall Configuration

You'll need to modify the CentOS firewall to accept connections on port 4444.

Insert this into the /etc/sysconfig/iptables file.

-A INPUT -m state --state NEW -m tcp -p tcp --dport 4444 -j ACCEPT

Add this line before the INPUT -j REJECT statements.

Here's a working example:

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 4444 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Testing (Optional)

Here is a quick way to test if the system is working correctly using Python.

yum -y python-pip
python-pip install -U selenium

Create a file named test_selenium.py and add the following lines of code.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Quick test of the headless Selenium server """

from selenium import webdriver

browser = webdriver.Remote(
    command_executor='http://127.0.0.1:4444/wd/hub',
    desired_capabilities={
        'browserName': 'firefox'
        }
)
browser.get('http://python.org')
browser.save_screenshot('test.png')
browser.quit()

Start a tail of the /var/log/selenium/selenium.log file.

tail -f /var/log/selenium/selenium.log

Now execute the script and you should see test.png screenshot file appear as output. The Selenium log should show the job request without errors.

python test_selenium.py

selenium-server's People

Contributors

ninjix avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.