Y
Y
Yuri2018-02-01 22:34:29
Ruby on Rails
Yuri, 2018-02-01 22:34:29

Why in copybara and poltergeist, after entering the page in a cycle, I can’t go to the next element?

Greetings!
There is a page with a list of links that you need to go through, go to each one, do something there (maybe also follow the link on it). The problem is that after going through the first link, the next one does not go any more.

url1 = '....'
@browser = Capybara.current_session
@browser.visit url1
@browser.all '.registerBox table'.each do |item|
    link_on_uid = item.first '.descripTd dt a'
    url2 = link_on_uid['href']
    puts url2
    @browser.visit url2
    @browser.all('.boxWrapper>table>tbody>tr').each do |tr|
        .....
    end
    puts 123
end

Approximately such code. I run it in the console, after puts 123 nothing happens for a long time, and then the process ends without errors. As a result, there are only two lines in the console - the page address and 123.
If you comment out the link in the url2 variable, then all the necessary links from the page are displayed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zaporozhchenko Oleg, 2018-02-03
@c3gdlk

Capybara is completely similar to the user's actions. Try to repeat with your hands. As soon as you click on the first link, a new page will open, on which there will no longer be the original list of links.
It is convenient for capybara to use save_and_open_page method for debugging

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question