Last active
December 31, 2017 02:43
-
-
Save tetsuyainfra/49c7ea6928a5ada7ab52f8c4347e250f to your computer and use it in GitHub Desktop.
Rails5.1 SystemTest with Chromium Headless mode ref: https://qiita.com/tetsuyainfra/items/b504510ea9110765e07c
This file contains hidden or 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
require "test_helper" | |
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase | |
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( | |
chromeOptions: { | |
args: %w(no-sandbox headless disable-gpu window-size=1280x800) | |
} | |
) | |
driven_by :selenium, using: :chrome, | |
options: { desired_capabilities: capabilities } | |
end |
This file contains hidden or 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
sudo apt install chromedriver | |
sudo apt install fonts-ipafont-gothic fonts-ipafont-mincho |
This file contains hidden or 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
# コアダンプ | |
$ chromium --screenshot http://google.com/ | |
$ chromium --headles --screenshot http://google.com/ | |
$ chromium --headles --disable-gpu --screenshot http://google.com/ | |
# 結局これでおk | |
$ chromium --no-sandbox --headless --disable-gpu --screenshot http://google.com/ |
This file contains hidden or 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
# コアダンプ | |
$ chromium --screenshot http://google.com/ | |
$ chromium --headles --screenshot http://google.com/ | |
$ chromium --headles --disable-gpu --screenshot http://google.com/ | |
# 結局これでおk | |
$ chromium --no-sandbox --headless --disable-gpu --screenshot http://google.com/ |
This file contains hidden or 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
puts Rails.env | |
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( | |
chromeOptions: { | |
# binary: "/usr/bin/chromium", # 必要なし | |
args: %w(no-sandbox headless disable-gpu window-size=1280x800) | |
} | |
) | |
driver = Selenium::WebDriver.for :chrome, | |
desired_capabilities: capabilities | |
driver.navigate.to "http://google.com" | |
element = driver.find_element(name: 'q') | |
element.send_keys "Hello WebDriver!" | |
element.submit | |
puts driver.title | |
driver.quit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment