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
Work just fine.
Thank you.