Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在陈旧的Rails应用程序中识别新javascript错误的来源_Javascript_Ruby On Rails 4_Rspec_Capybara_Poltergeist - Fatal编程技术网

如何在陈旧的Rails应用程序中识别新javascript错误的来源

如何在陈旧的Rails应用程序中识别新javascript错误的来源,javascript,ruby-on-rails-4,rspec,capybara,poltergeist,Javascript,Ruby On Rails 4,Rspec,Capybara,Poltergeist,试图“解冻”一个已有一年历史的项目,却发现一些奇怪的javascript错误。我没有太多的运气去寻找解决方案 我猜这与我的开发盒上的某些东西太新(或太旧)而无法使用此代码库有关,但不确定解决此问题的最佳方法 有什么想法可以解决这个问题吗 谢谢你的帮助 以下是规格: # ./spec/support/helpers/comments_page_helpers ... def open_image_comments_modal(section_position:, photo_posit

试图“解冻”一个已有一年历史的项目,却发现一些奇怪的javascript错误。我没有太多的运气去寻找解决方案

我猜这与我的开发盒上的某些东西太新(或太旧)而无法使用此代码库有关,但不确定解决此问题的最佳方法

有什么想法可以解决这个问题吗

谢谢你的帮助

以下是规格:

  # ./spec/support/helpers/comments_page_helpers
  ...
  def open_image_comments_modal(section_position:, photo_position:)
    selector = "editable-section:nth-child(#{section_position}) " \
      "li.photo:nth-child(#{photo_position})"

    within selector do
      find('a.image-wrapper img').click        ### <== line #23
    end

    expect(page).to have_css('.modal-comments-container')
  end
  ...
。/spec/support/helpers/comments\u page\u helpers
...
def打开图像注释模式(截面位置:,照片位置:)
选择器=“可编辑部分:第n个子项(#{section\u position})”\
“李。照片:第n个孩子(#{photo_position})”
在选择器do内

查找('a.image-wrapper img')。单击#####JS错误会告诉您问题所在-您无权访问
/api/v1/comments
,这是从请求返回到您自己的应用程序吗?还是来自外部服务的请求?此外,你使用的是恶鬼,这基本上相当于6-7岁版本的Safari在这一点上。如果你正在用JS/CSSrequest for
/api/v1/comments
对我们自己的应用程序进行回调,那么最好通过selenium驱动程序使用headless Chrome或Firefox。不确定为什么在测试期间应用程序运行时它不会响应?该应用程序已经“休眠”一年了。我被要求“解冻”它。在迁移到chromedriver之前,我想先通过以前的测试。正在寻找解决此问题的最佳方法。它正在响应一个401未授权错误——请检查rails test.log以了解请求被拒绝的原因。
5) Comment creation for image behaves like added comment adds single comment
     Failure/Error: find('a.image-wrapper img').click

     Capybara::Poltergeist::JavascriptError:
       One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).

       Possibly unhandled rejection: {"data":{"message":"unauthorized"},"status":401,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/api/v1/comments","params":{"commentable_id":4179,"commentable_type":"Attachment"},"headers":{"Accept":"application/json"}},"statusText":"Unauthorized "}
       Possibly unhandled rejection: {"data":{"message":"unauthorized"},"status":401,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"/api/v1/comments","params":{"commentable_id":4179,"commentable_type":"Attachment"},"headers":{"Accept":"application/json"}},"statusText":"Unauthorized "}
           at http://127.0.0.1:50066/assets/application-f59647de5de8bec0c768ec8da4dfa097f8e2db01844d3e5d71b6a6dd8b15abfb.js:26422
     Shared Example Group: "added comment" called from ./spec/features/comments/creation_spec.rb:76
     # ./spec/support/helpers/comments_page_helpers.rb:23:in `block in open_image_comments_modal'
     # ./spec/support/helpers/comments_page_helpers.rb:22:in `open_image_comments_modal'
     # ./spec/features/comments/creation_spec.rb:69:in `block (3 levels) in <top (required)>'