ruby - Capybara 'visit' 不考虑 URL 中的 '#' 字符?

标签 ruby selenium capybara

我遇到了一个奇怪的问题,我将我的应用程序主机设置为远程站点,如下所示:

Capybara.configure do |config|
  config.default_max_wait_time = 10 # seconds
  config.default_driver        = :selenium_chrome
  config.app_host              = 'https://dev.stagingsite.com/widget-web/#/'
end

所有相对路径都在 /#/ 之后,所以在我的访问方法中(例如 session.visit('login') 将带我到 URL:

https://dev.stagingsite.com/widget-web/login#/

我试过在不同的地方添加“/”,转义 # 但它似乎无法将相对 url 放在 # 之后,而是总是尝试把它放在 widget-web/

之后

知道这里发生了什么吗?

最佳答案

来自 MDN 的 URL 文档:

It is worth noting that the part after the #, also known as the fragment identifier, is never sent to the server with the request.

检查您的服务器日志;您会看到任何对 /widget-web/#/ 的请求都会作为对 /widget-web/ 的请求发送。 # 阻止将其后的任何内容发送到服务器。

What is a URL? docs

关于ruby - Capybara 'visit' 不考虑 URL 中的 '#' 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57529387/

相关文章:

ruby-on-rails - 如何使用 Capybara 结合查找和内部?

javascript - Capybara 重定向到 JSON 响应

ruby - File.open 忽略路径

ruby - 如何返回多维数组中字符串的坐标/索引? [ ruby ]

java - Selenium: 查找元素 "next to"其他元素

python - 如何通过多行和每行单元格的表格中的部分文本查找元素?

ruby-on-rails - Rspec+Capybara - 它不会改变任何记录?

ruby - 将数据解析为新行上的 csv 文件 - ruby

ruby-on-rails - 创建 redmine 插件

Selenium + Google Colab 错误 : 'chromedriver' executable needs to be in PATH