- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
热衷于将 Capybara 烘焙到新版本的 Rails (5.1) cf http://weblog.rubyonrails.org/2017/2/23/Rails-5-1-beta1/
我遇到了一个问题。这是我的步骤。欢迎任何线索。
全新安装:
~$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
~$ rails -v
Rails 5.1.0.beta1
~$ mkdir railsapps
~$ cd railsapps
~/railsapps$ rails new smoketestapp
~/railsapps$ cd smoketestapp
~/railsapps/smoketestapp$ rails generate scaffold post title:string body:text
~/railsapps/smoketestapp$ rails db:migrate
~/railsapps/smoketestapp$ cat test/system/posts_test.rb
require "application_system_test_case"
class PostsTest < ApplicationSystemTestCase
test "visiting the index" do
visit posts_url
assert_selector "h1", text: "Post"
end
end
~/railsapps/smoketestapp$ rake test TEST=test/system/posts_test.rb
Run options: --seed 55778
# Running:
...
Error:
PostsTest#test_visiting_the_index:
Selenium::WebDriver::Error::WebDriverError: Unable to find chromedriver. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.
...
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
~/railsapps/smoketestapp$
chromedriver
):
~/railsapps/smoketestapp$ ls /usr/bin/google-chrome
lrwxrwxrwx 1 root root 31 Mar 18 15:31 /usr/bin/google-chrome -> /etc/alternatives/google-chrome*
~/railsapps/smoketestapp$ echo $PATH
...:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:...
~/railsapps/smoketestapp$ wget https://chromedriver.storage.googleapis.com/2.28/chromedriver_linux64.zip
~/railsapps/smoketestapp$ unzip chromedriver_linux64.zip
~/railsapps/smoketestapp$ sudo cp chromedriver /usr/local/bin
~/railsapps/smoketestapp$ ls /usr/local/bin
total 7504
drwxr-xr-x 2 root root 4096 Mar 19 19:05 ./
drwxr-xr-x 10 root root 4096 Okt 12 22:42 ../
-rwxr-xr-x 1 root root 7673176 Mar 19 19:05 chromedriver*
~/railsapps/smoketestapp$
~/railsapps/smoketestapp$ rake test TEST=test/system/posts_test.rb
Run options: --seed 51574
# Running:
...
Error:
PostsTest#test_visiting_the_index:
Net::ReadTimeout: Net::ReadTimeout test/system/posts _test.rb:5:in `block in '
...
bin/rails test test/system/posts_test.rb:4
...
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
~/railsapps/smoketestapp$
rails -v
时给出了有关“Net::ReadTimeout: Net::ReadTimeout”错误消息根本原因的线索在应用程序目录中,给出 Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start:
~/railsapps/smoketestapp$ rails -v
Run options: --seed 39896
# Running:
.......E
Error:
PostsTest#test_visiting_the_index:
Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.28.455506 (18f6627e265f442aeec9b6661a49fe819aeeea1f),platform=Linux 4.8.0-41-generic x86_64)
test/system/posts_test.rb:5:in `block in <class:PostsTest>'
Error:
PostsTest#test_visiting_the_index:
Net::ReadTimeout: Net::ReadTimeout
bin/rails test test/system/posts_test.rb:4
...
~/railsapps/smoketestapp$
~/railsapps/smoketestapp$ irb
2.4.0 :001 > require "selenium-webdriver"
=> true
2.4.0 :002 > driver = Selenium::WebDriver.for(:chrome)
Net::ReadTimeout: Net::ReadTimeout
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/protocol.rb:176:in `rbuf_fill'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/protocol.rb:154:in `readuntil'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/protocol.rb:164:in `readline'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/http/response.rb:40:in `read_status_line'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/http/response.rb:29:in `read_new'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/http.rb:1446:in `block in transport_request'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/http.rb:1443:in `catch'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/http.rb:1443:in `transport_request'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/http.rb:1416:in `request'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/http.rb:1409:in `block in request'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/http.rb:877:in `start'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/net/http.rb:1407:in `request'
from ~/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/default.rb:124:in `response_for'
from ~/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/default.rb:78:in `request'
from ~/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/common.rb:61:in `call'
from ~/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/bridge.rb:669:in `raw_execute'
from ~/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/bridge.rb:108:in `create_session'
from ~/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/bridge.rb:71:in `initialize'
from ~/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/chrome/bridge.rb:52:in `initialize'
from ~/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/common/driver.rb:61:in `new'
from ~/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/common/driver.rb:61:in `for'
from ~/.rvm/gems/ruby-2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver.rb:87:in `for'
from (irb):2
from ~/.rvm/rubies/ruby-2.4.0/bin/irb:11:in `<main>'
2.4.0 :003 > exit
~/railsapps/smoketestapp$
require "selenium-webdriver"
Selenium::WebDriver::Chrome.driver_path="/usr/local/bin/chromedriver"
Selenium::WebDriver.for :chrome, :service_log_path => "/tmp/cd.log"
driver = Selenium::WebDriver.for(:chrome)
~/railsapps/smoketestapp$ tail /tmp/cd.log
...
[0.247][INFO]: Launching chrome: /opt/google/chrome/google-chrome --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --disable-web-resources --enable-logging --full-memory-crash-report --ignore-certificate-errors --load-extension=/tmp/.org.chromium.Chromium.Pdre6o/internal --logging-level=1 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12264 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.mHJaEd data:,
[0.250][WARNING]: PAC support disabled because there is no system implementation
[20.281][INFO]: RESPONSE InitSession unknown error: Chrome failed to start: exited abnormally
~/railsapps/smoketestapp$
~$ google-chrome
[3938:3938:0320/213941.129923:ERROR:browser_main_loop.cc(279)] Gtk: cannot open display:
irb(main):001:0> require "selenium-webdriver"
=> true
irb(main):002:0> Selenium::WebDriver::Chrome.driver_path="/usr/local/bin/chromedriver"
=> "/usr/local/bin/chromedriver"
irb(main):003:0> driver = Selenium::WebDriver.for(:chrome)
=> #<Selenium::WebDriver::Driver:0x59d7c889a916c6b8 browser=:chrome>
irb(main):004:0> driver.navigate.to("http://www.google.com")
Selenium::WebDriver::Error::UnknownError: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"10797.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=57.0.2987.110)
(Driver info: chromedriver=2.4.226074,platform=Linux 4.8.0-41-generic x86_64)
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/common.rb:83:in `new'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/common.rb:83:in `create_response'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/default.rb:107:in `request'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/http/common.rb:61:in `call'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/bridge.rb:669:in `raw_execute'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/bridge.rb:647:in `execute'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/remote/bridge.rb:120:in `get'
from ~/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.3.0/lib/selenium/webdriver/common/navigation.rb:32:in `to'
from (irb):4
from ~/.rvm/rubies/ruby-2.4.0/bin/irb:11:in `<main>'
irb(main):005:0> exit
最佳答案
最终,我想使用 Capybara 在我的设置中运行系统测试(开发机器 = 带有操作系统的 VM = Linux Ubuntu,通过 PuTTY 远程访问)。
我找到了让它工作的方法。
为此,我放弃了 Chrome 及其 Selenium 驱动程序,转而使用 PhantomJS 和 poltergeist。
PhantomJS 是一个 headless 浏览器(= 没有 GUI)。它工作得很好。这是我的步骤(Rails 5.1):
#gem 'selenium-webdriver'
gem 'poltergeist'
bundle update
application_system_test_case.rb
中),注释掉 chrome 驱动配置:$ cat test/application_system_test_case.rb
require "test_helper"
require "capybara/poltergeist"
Capybara.javascript_driver = :poltergeist
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
# driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
driven_by :poltergeist
end
$ wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
$ tar -xjvf phantomjs-1.9.8-linux-x86_64.tar.bz2
$ sudo cp phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/bin
$ sudo chmod +x /usr/local/bin/phantomjs
$ rake test TEST=test/system/posts_test.rb
Run options: --seed 38196
# Running:
Puma starting in single mode...
* Version 3.8.2 (ruby 2.4.0-p0), codename: Sassy Salamander
* Min threads: 0, max threads: 1
* Environment: test
* Listening on tcp://0.0.0.0:44265
Use Ctrl-C to stop
You're running an old version of PhantomJS, update to >= 2.1.1 for a better experience.
.
Finished in 1.366478s, 0.7318 runs/s, 0.7318 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
$
关于ruby-on-rails - Net::ReadTimeout: Net::ReadTimeout 和 Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start on Rails 5.1.beta 系统测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42891801/
我看过一些与 Selenium 中的超时错误相关的帖子。这变得越来越难以忍受,因为它使我的测试包无法使用。我正在测试当前正在开发中的网页。 我有一个包含大约 300 个测试场景的回归套件,在 fire
我用过 httparty Rails 4 应用程序中的 gem 当我发布到 api 时,查询正在服务器中运行,但我的控制台因错误 Net::ReadTimeout: Net::ReadTimeout
我今天放假回来,我的 capybara 和 Selenium 动力测试抛出了这个错误: Net::ReadTimeout: Net::ReadTimeout /Users/pupeno/.rvm/ru
热衷于将 Capybara 烘焙到新版本的 Rails (5.1) cf http://weblog.rubyonrails.org/2017/2/23/Rails-5-1-beta1/ 我遇到了一个
我试图了解 restTemplate 上可用的 readTimeout,它到底是什么? 它是在我们收到超时异常之前请求可以花费的总时间吗? 最佳答案 您可以在 RestTemplate 上定义读取超时
对于我的测试服务器,我有无复制 Cassandra 2.1.6 设置: CREATE KEYSPACE v2 WITH replication ={'class': 'SimpleStrategy',
我有一个 Zuul 代理,它工作正常,直到它重定向到一个比正常时间(超过 10 秒)响应时间更长的服务器。 我可以通过属性 (zuul.host.socket-timeout-millis) 修改读取
我正在使用 Ruby/Cucumber/Capybara/Chromedriver 运行自动化测试。自动化测试由 Jenkins 运行。奇怪的是,有时浏览器打开,但黑屏,我得到 Net::ReadTi
我正在尝试使用 Python 和请求抓取 Home Depot 网站。 Selenium Webdriver 工作正常,但需要太多时间,因为目标是在本地油漆店和电动工具店之间制作一个对时间敏感的价格比
我们遇到一个问题,在我们产品的单个实例上,当我们尝试设置 System.Net.HttpWebResponse 对象的 ReadTimeout 属性时收到 InvalidOperationExcept
我在我的代码中使用了 URLConnection。我已将 ReadTimeout 设置为 5 秒,但它没有生效。当我关闭 wifi 时,会立即调用 IO 异常。 URLConnection conn
当客户端使用 readTimeout 关闭与 API 的连接时,服务器会发生什么。请求的执行将完成还是一旦超时发生就会中断,或者执行将完成并且响应流被服务器应该发送给用户的响应 最佳答案 超时是关闭连
我已经在 Virtual Box 上安装了 hortonworks 沙箱。 (6092MB 内存)我正在关注 this tutorial . 当我尝试执行一个简单的脚本时 使用参数:-useHCata
我正在使用 httparty 进行一系列 API 调用。前两个 API 调用成功,但第三个失败。它暂停大约 60 秒(默认超时时间),然后返回此错误: /Users/luigi/.rvm/rubies
在为这个简单问题找到答案所花费的时间似乎比合理的多得多之后,我想我应该将我的结果留在这里,这样其他人就不必跳过我刚刚遵循的所有障碍和错误路径。 问题是,如果您使用 TcpClient ReadTime
NetworkStream.ReadAsync 什么时候任务完成?一旦接收到指定长度的数据? 如果是,它会返回 0 吗?然后 CancellationToken可以用作 ReadTimeout ,这是
在一些与支付终端通信的遗留代码中发现了一个错误。 就在开始新的支付之前,代码尝试清除 SerialPort 的内部读取缓冲区。 我将代码精简到最低限度。它使用 .NET SerialPort 类型。设
在使用 Watir 进行身份验证后,我正在尝试使用 Watir 获取 Facebook 的源代码。它给出了这个特定的错误。 /.rvm/rubies/ruby-2.0.0-p247/lib/ruby/
我在以下代码中遇到异常: (System.IO.MemoryStream) Stream stream = new MemoryStream(fcr.FileContents); System.Dra
我对如何使用 ReadTimeout 以及它如何影响 Read() 感到困惑。 当尝试读取网络流时,有 3 种情况,假设我们正在尝试读取 X 个字节: 数据可用,字节 X 没有可用数据,ReadTim
我是一名优秀的程序员,十分优秀!