Ruby: 找不到水豚 find() 元素

Ruby: Capybara find() Element not found

def perform_search

fill_in 'q', :with => @skillset
fill_in 'l', :with => @region
find('#fj').click
find("#refineresults", text: "date").click_link
sleep(1)
end

来源:https://github.com/jmopr/job-hunter/blob/master/scraper.rb

尝试 indeed.com 通过单击日期超链接按日期而不是相关性排序。谁能指出我在代码中的第 4 行出错的地方?

click_link 接受参数来识别link 它将被点击。要单击 div 中的 "date" link,id 为 refineresults,您可以执行

find("#refineresults").click_link("date")

如果您想手动查找元素而不是使用 click_link,您可以这样做

find("#refineresults a", text: "date").click

虽然我认为之前的解决方案更清楚你实际在做什么

注意:将来 post 提出问题时,post 您的代码产生的实际错误,这将使人们更容易帮助您