Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.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
Ruby 使用click_链接时出现错误的URI(不是URI?)_Ruby_Hyperlink_Capybara - Fatal编程技术网

Ruby 使用click_链接时出现错误的URI(不是URI?)

Ruby 使用click_链接时出现错误的URI(不是URI?),ruby,hyperlink,capybara,Ruby,Hyperlink,Capybara,我的代码行如下所示: click_link "link page with spaces" 该链接在HTML中看起来如下所示: <a href="page with spaces">link page with spaces</a> 我知道问题是因为链接包含未转换为%20的空格,但我不确定如何解决它。您能在生成uri的任何位置转义它吗 require 'uri' URI.escape("page with spaces") # => "page%20with%2

我的代码行如下所示:

click_link "link page with spaces"
该链接在HTML中看起来如下所示:

<a href="page with spaces">link page with spaces</a>

我知道问题是因为链接包含未转换为
%20
的空格,但我不确定如何解决它。

您能在生成uri的任何位置转义它吗

require 'uri'
URI.escape("page with spaces") # => "page%20with%20spaces"

给出实际的html,以便我们可以看到它。@ArupRakshit我给了href。还缺少什么?@我说的url链接:)@阿鲁普拉克希特哦,我不能,它在内部网络。我知道问题在于空间。我还看到其他一些帖子有这个问题,但它们都没有使用
点击链接
@ArupRakshit-解决方法是在使用链接之前总是在链接上运行
URI.parse
。但是在这种情况下我不能这样做,因为
click\u link
会调用linkno。生成URI的页面不在我的控制之下。
require 'uri'
URI.escape("page with spaces") # => "page%20with%20spaces"