Created
May 26, 2018 02:21
-
-
Save b4oshany/18b0b84524a5ba9c853fb179b522780b to your computer and use it in GitHub Desktop.
Python Robot Framework with Headless Chrome Setup and Robot Files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** Keywords *** | |
Open Chrome | |
[Arguments] ${url} | |
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver | |
Call Method ${chrome_options} add_argument --disable-extensions | |
Call Method ${chrome_options} add_argument --headless | |
Call Method ${chrome_options} add_argument --disable-gpu | |
Call Method ${chrome_options} add_argument --no-sandbox | |
Create Webdriver Chrome chrome_options=${chrome_options} | |
Set Window Size 1024 768 | |
Go To ${url} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# from https://chromium.woolyss.com/ | |
# and https://gist.github.com/addyosmani/5336747 | |
# and https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md | |
apt-get update | |
if [ -z $(which node) ]; then | |
curl -sL https://deb.nodesource.com/setup_8.x | bash - | |
apt-get install -y nodejs | |
fi | |
if [ -z $(which npm) ]; then | |
apt-get install -y npm | |
fi | |
apt-get install -y libappindicator1 fonts-liberation | |
apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable | |
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb | |
dpkg -i google-chrome*.deb | |
apt-get -f -y install | |
dpkg --configure -a | |
dpkg -i google-chrome*.deb | |
npm install chromedriver -g --unsafe-perm=true --allow-root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** Settings *** | |
Library Selenium2Library | |
Suite Teardown Close All Browsers | |
Test Setup Open Chrome | |
*** Keywords *** | |
Open Chrome | |
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver | |
Call Method ${chrome_options} add_argument --disable-extensions | |
Call Method ${chrome_options} add_argument --headless | |
Call Method ${chrome_options} add_argument --disable-gpu | |
Call Method ${chrome_options} add_argument --no-sandbox | |
Create Webdriver Chrome chrome_options=${chrome_options} | |
*** Test Cases *** | |
Go to google | |
Go To https://google.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this use my mac's browser in headless mode? If yes, my current version of chrome is 76 and everytime i run the automation locally, it throws "SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 74
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Mac OS X 10.13.6 x86_64)"