├── config.json ├── README.md ├── Ubuntu.sh └── Centos.sh /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "capabilities": [ 3 | { 4 | "browserName": "chrome", 5 | "maxInstances": 1, 6 | "seleniumProtocol": "WebDriver" 7 | } 8 | ], 9 | "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", 10 | "maxSession": 1, 11 | "port": 5555, 12 | "register": true, 13 | "registerCycle": 5000 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Selenium Chrome 2 | 3 | 4 | #### Ubuntu 5 | ``` 6 | # Ubuntu-16.04-x86_64 7 | # Selenium Server 3.0.1 8 | # Google Chrome 55.0.2883.87 9 | # Chrome Driver 2.25 10 | # Open JDK 1.8.0 11 | ``` 12 | 13 | ``` 14 | wget --no-check-certificate --no-verbose https://raw.githubusercontent.com/speed/selenium/master/Ubuntu.sh -O Selenium-Chrome.sh \ 15 | && sh Selenium-Chrome.sh 16 | ``` 17 | 18 | #### Centos 19 | 20 | ``` 21 | # Centos-7-x86_64-minimal 22 | # Selenium Server 3.0.1 23 | # Google Chrome 55.0.2883.87 24 | # Chrome Driver 2.25 25 | # Open JDK 1.8.0 26 | ``` 27 | 28 | ``` 29 | wget --no-check-certificate --no-verbose https://raw.githubusercontent.com/speed/selenium/master/Centos.sh -O Selenium-Chrome.sh \ 30 | && sh Selenium-Chrome.sh 31 | ``` 32 | 33 | 34 | #### Docker chrome 35 | https://github.com/SeleniumHQ/docker-selenium 36 | 37 | Chrome plugin 38 | ```bash 39 | mkdir -p /opt/selenium \ 40 | && wget --no-verbose -O /opt/selenium/ModHeader.crx https://raw.githubusercontent.com/speed/newcrawler-plugin-urlfetch-chrome/master/crx/ModHeader.crx\ 41 | && chmod 755 /opt/selenium/ModHeader.crx 42 | ``` 43 | 44 | Chrome 45 | ``` bash 46 | $ docker run -d -p 4444:4444 --net=host --name=chrome -e JAVA_OPTS=-Xmx512m --shm-size=1g selenium/standalone-chrome:3.11.0-antimony 47 | ``` 48 | Firefox 49 | ``` bash 50 | $ docker run -d -p 4444:4444 --net=host --name=chrome -e JAVA_OPTS=-Xmx512m --shm-size=1g selenium/standalone-firefox:3.11.0-antimony 51 | ``` 52 | -------------------------------------------------------------------------------- /Ubuntu.sh: -------------------------------------------------------------------------------- 1 | #================================================ 2 | # Ubuntu-16.04-x86_64 3 | #================================================ 4 | 5 | 6 | #================================================ 7 | # Customize sources for apt-get 8 | #================================================ 9 | 10 | echo "deb http://archive.ubuntu.com/ubuntu xenial main universe" > /etc/apt/sources.list \ 11 | && echo "deb http://archive.ubuntu.com/ubuntu xenial-updates main universe" >> /etc/apt/sources.list \ 12 | && echo "deb http://security.ubuntu.com/ubuntu xenial-security main universe" >> /etc/apt/sources.list 13 | 14 | #======================== 15 | # Miscellaneous packages 16 | # Includes minimal runtime used for executing non GUI Java programs 17 | #======================== 18 | 19 | apt-get update -qqy \ 20 | && apt-get -qqy --no-install-recommends install \ 21 | bzip2 \ 22 | ca-certificates \ 23 | openjdk-8-jre-headless \ 24 | sudo \ 25 | unzip \ 26 | wget \ 27 | && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \ 28 | && sed -i 's/securerandom\.source=file:\/dev\/random/securerandom\.source=file:\/dev\/urandom/' /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/java.security 29 | 30 | #========== 31 | # Selenium 32 | #========== 33 | mkdir -p /opt/selenium \ 34 | && wget --no-verbose https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar -O /opt/selenium/selenium-server-standalone.jar 35 | 36 | #======================================== 37 | # Add normal user with passwordless sudo 38 | #======================================== 39 | sudo useradd seluser --shell /bin/bash --create-home \ 40 | && sudo usermod -a -G sudo seluser \ 41 | && echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \ 42 | && echo 'seluser:secret' | chpasswd 43 | 44 | #============== 45 | # VNC and Xvfb 46 | #============== 47 | 48 | apt-get update -qqy \ 49 | && apt-get -qqy install \ 50 | xvfb \ 51 | && rm -rf /var/lib/apt/lists/* /var/cache/apt/* 52 | 53 | #============================================ 54 | # Google Chrome 55 | #============================================ 56 | # can specify versions by CHROME_VERSION; 57 | # e.g. google-chrome-stable=53.0.2785.101-1 58 | # google-chrome-beta=53.0.2785.92-1 59 | # google-chrome-unstable=54.0.2840.14-1 60 | # latest (equivalent to google-chrome-stable) 61 | # google-chrome-beta (pull latest beta) 62 | #============================================ 63 | wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ 64 | && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \ 65 | && apt-get update -qqy \ 66 | && apt-get -qqy install google-chrome-stable \ 67 | && rm /etc/apt/sources.list.d/google-chrome.list \ 68 | && rm -rf /var/lib/apt/lists/* /var/cache/apt/* 69 | 70 | #================== 71 | # Chrome webdriver 72 | #================== 73 | wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip \ 74 | && rm -rf /opt/selenium/chromedriver \ 75 | && unzip /tmp/chromedriver_linux64.zip -d /opt/selenium \ 76 | && rm /tmp/chromedriver_linux64.zip \ 77 | && chmod 755 /opt/selenium/chromedriver \ 78 | && ln -fs /opt/selenium/chromedriver /usr/bin/chromedriver 79 | 80 | chmod +x /opt/google/chrome/google-chrome 81 | chown -R seluser:seluser /opt/selenium 82 | 83 | #==================================== 84 | # Run Selenium Standalone 85 | #==================================== 86 | #su - seluser -c "nohup xvfb-run -n 99 --server-args=\"-screen 0 1024x768x8 -ac +extension RANDR\" java -jar /opt/selenium/selenium-server-standalone.jar -role hub &" 87 | 88 | #http://127.0.0.1:5555/wd/hub 89 | #su - seluser -c "nohup xvfb-run -n 98 --server-args=\"-screen 0 1024x768x8 -ac +extension RANDR\" java -Dwebdriver.chrome.driver=/opt/selenium/chromedriver -jar /opt/selenium/selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register/ &" 90 | 91 | #http://127.0.0.1:4444/wd/hub 92 | su - seluser -c "nohup xvfb-run -n 99 --server-args=\"-screen 0 1024x768x8 -ac +extension RANDR\" java -jar /opt/selenium/selenium-server-standalone.jar &" 93 | 94 | -------------------------------------------------------------------------------- /Centos.sh: -------------------------------------------------------------------------------- 1 | #================================================ 2 | # Centos-7-x86_64-minimal 3 | #================================================ 4 | 5 | 6 | #======================== 7 | # Miscellaneous packages 8 | # Includes minimal runtime used for executing non GUI Java programs 9 | #======================== 10 | 11 | ps -ef | grep selenium | grep -v grep | cut -c 9-15 | xargs kill -s 9 12 | ps -ef | grep chrome | grep -v grep | cut -c 9-15 | xargs kill -s 9 13 | 14 | yum update -y \ 15 | && yum -y install \ 16 | bzip2 \ 17 | ca-certificates \ 18 | java-1.8.0-openjdk-headless \ 19 | sudo \ 20 | unzip \ 21 | wget \ 22 | && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \ 23 | && sed -i 's/securerandom\.source=file:\/dev\/random/securerandom\.source=file:\/dev\/urandom/' /usr/lib/jvm/jre-1.8.0-openjdk/lib/security/java.security 24 | 25 | #========== 26 | # Selenium 27 | # https://www.seleniumhq.org/download/ 28 | #========== 29 | seleniumlastrelease=`curl --silent 'https://www.seleniumhq.org/download/' | grep -o -E 'Download version .*+' | grep -o -E 'https://[^"]*'` 30 | 31 | mkdir -p /opt/selenium \ 32 | && rm -rf /opt/selenium/selenium-server-standalone.jar \ 33 | && wget --no-verbose $seleniumlastrelease -O /opt/selenium/selenium-server-standalone.jar 34 | 35 | #======================================== 36 | # Add normal user with passwordless sudo 37 | #======================================== 38 | sudo useradd seluser --shell /bin/bash --create-home \ 39 | && sudo usermod -a -G wheel seluser \ 40 | && echo '%wheel ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \ 41 | && echo 'seluser:secret' | chpasswd 42 | 43 | #============== 44 | # VNC and Xvfb 45 | #============== 46 | 47 | yum update -y \ 48 | && yum -y install \ 49 | Xvfb libXfont Xorg \ 50 | && yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"\ 51 | && rm -rf /var/lib/apt/lists/* /var/cache/apt/* 52 | 53 | 54 | 55 | #============================================ 56 | # Google Chrome 57 | #============================================ 58 | # can specify versions by CHROME_VERSION; 59 | # e.g. google-chrome-stable=53.0.2785.101-1 60 | # google-chrome-beta=53.0.2785.92-1 61 | # google-chrome-unstable=54.0.2840.14-1 62 | # latest (equivalent to google-chrome-stable) 63 | # google-chrome-beta (pull latest beta) 64 | #============================================ 65 | 66 | cat << EOF > /etc/yum.repos.d/google-chrome.repo 67 | [google-chrome] 68 | name=google-chrome - \$basearch 69 | baseurl=http://dl.google.com/linux/chrome/rpm/stable/\$basearch 70 | enabled=1 71 | gpgcheck=1 72 | gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub 73 | EOF 74 | 75 | yum update -y \ 76 | && yum -y remove google-chrome-stable \ 77 | && yum -y install google-chrome-stable \ 78 | && rm -rf /etc/yum.repos.d/google-chrome.repo \ 79 | && rm -rf /var/lib/apt/lists/* /var/cache/apt/* 80 | 81 | #================== 82 | # Chrome webdriver 83 | # http://chromedriver.chromium.org/downloads 84 | #================== 85 | chromedriverlastrelease=`curl --silent 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE'` 86 | wget --no-verbose -O /tmp/chromedriver_linux64.zip "https://chromedriver.storage.googleapis.com/$chromedriverlastrelease/chromedriver_linux64.zip" \ 87 | && rm -rf /opt/selenium/chromedriver \ 88 | && unzip /tmp/chromedriver_linux64.zip -d /opt/selenium \ 89 | && rm -rf /tmp/chromedriver_linux64.zip \ 90 | && chmod 755 /opt/selenium/chromedriver \ 91 | && ln -fs /opt/selenium/chromedriver /usr/bin/chromedriver 92 | 93 | #================== 94 | # Chrome crx 95 | #================== 96 | rm -rf /opt/selenium/ModHeader.crx \ 97 | && wget --no-verbose -O /opt/selenium/ModHeader.crx "https://raw.githubusercontent.com/speed/newcrawler-plugin-urlfetch-chrome/master/crx/ModHeader.crx"\ 98 | && chmod 755 /opt/selenium/ModHeader.crx 99 | 100 | chmod +x /opt/google/chrome/google-chrome 101 | chown -R seluser:seluser /opt/selenium 102 | 103 | #==================================== 104 | # Run Selenium Standalone 105 | #==================================== 106 | #su - seluser -c "nohup xvfb-run -n 99 --server-args=\"-screen 0 1024x768x8 -ac +extension RANDR\" java -jar /opt/selenium/selenium-server-standalone.jar -role hub &" 107 | 108 | #http://127.0.0.1:5555/wd/hub 109 | #su - seluser -c "nohup xvfb-run -n 98 --server-args=\"-screen 0 1024x768x8 -ac +extension RANDR\" java -Dwebdriver.chrome.driver=/opt/selenium/chromedriver -jar /opt/selenium/selenium-server-standalone.jar -role node -hub http://localhost:4444/grid/register/ &" 110 | 111 | #http://127.0.0.1:4444/wd/hub 112 | su - seluser -c "(xvfb-run -n 99 --server-args=\"-screen 0 1024x768x8 -ac +extension RANDR\" java -jar /opt/selenium/selenium-server-standalone.jar > /dev/null &)" 113 | 114 | --------------------------------------------------------------------------------