Watir Chrome无头码头

时间:2017-12-21 16:37:54

标签: ruby google-chrome selenium docker watir

我正试图通过在Docker上运行无头测试套件来简化我的Selenium测试。我正在运行Debian Jessie图像,安装了从PPA安装的google-chrome-stable和chromedriver 2.33。我还附加了/ dev / shm来最大化我在容器中的记忆。我已经验证了chromedriver在容器内运行良好。但是,当我运行一个简单的测试时,我会得到一个超时:

browser = Watir::Browser.new :chrome, headless: true
browser.goto 'google.com'
browser.text_field(title: 'Search').set 'Hello World!'
browser.button(type: 'submit').click
puts browser.title
browser.quit

/usr/local/lib/ruby/2.4.0/net/protocol.rb:176:in `rbuf_fill': Net::ReadTimeout (Net::ReadTimeout)
    from /usr/local/lib/ruby/2.4.0/net/protocol.rb:154:in `readuntil'
    from /usr/local/lib/ruby/2.4.0/net/protocol.rb:164:in `readline'
    from /usr/local/lib/ruby/2.4.0/net/http/response.rb:40:in 
......

有一点需要提及的是,chromedriver安装在/ chromedriver / chromedriver,然后添加到$ PATH。 Watir / Selenium需要知道chromedriver的完整路径吗? chromedriver或chrome是否需要在后台运行?

1 个答案:

答案 0 :(得分:0)

那是因为小shm(共享内存)。这个github link将解决您的麻烦。如果您好奇什么是shm,请参阅this不错的指南。

使用此命令可以完成快速测试。

docker exec containerID umount /dev/shm
docker exec containerID mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm