问题描述:

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

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

Trying to get indeed.com to sort by date instead of relevance by clicking on the date hyperlink. Can anyone point me to where i'm going wrong with the 4th line in the code?

网友答案:

click_link takes parameters to identify the link it's going to click on. To click on the "date" link in the div with id of refineresults you would do

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

If you wanted to find the element manually rather than using click_link you would do

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

although I think the previous solution is clearer as to what you're actually doing

Note: In the future when posting questions, post the actual error your code is producing, it will make it much easier for people to help you

相关阅读:
Top