ruby - watir open each link of a page -


i need scrape info on website has table each row contains link.

i want watir click each link in table, grab info generated page , go previous page.

t = browser.table(:class => "tblelencoprodotti")  t.links(:class => "txt10b").each |l|   l.click   #do stuff   browser.back end 

unfortunately action brings me "document expired document no longer available" error.

this works if manually operation on default ff session , hit arrow, somehow not work if in watir opened window.

any reason why need click , go browser each time?

why not store links , visit them 1 one:

browser.table(:class => "tblelencoprodotti").   links(:class => "txt10b").map(&:href).   each { |url| browser.goto url } 

update:

if links clickable due javascript magic, try this:

links_count = browser.table(:class => "tblelencoprodotti").links(:class => "txt10b").size links_count.times |index|   browser.table(:class => "tblelencoprodotti").links(:class => "txt10b")[index].click   browser.back end 

this solution should clear cache. i'm not sure, maybe there's better way relocate , not rely on cached elements.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -