Error is not skipped by next in a each loop

Hello everyone,

*edit: ‘at’ [email protected] (the ‘at sign’ is somewhat understood as mentioning an user). Formatting also returns an error. I am sorry for that. I don’t know how to solve this

I am new to ruby. I have a ‘for each’ loop for which I would like errors to be ignored so ot goes to the next item.
Yet, I must be missing something. Has somebody an idea?

require ‘selenium-webdriver’
require ‘rspec/expectations’
include RSpec::Matchers

def setup
'at’driver = Selenium::WebDriver.for :firefox
end

def teardown
'at’driver.quit
end

def run
setup
yield
teardown
end

run do
require ‘rest-client’

'at’driver.get ‘https://cottonon.com/SG/women/womens-lingerie/bras/unlined-bras/
all_images = @driver.find_elements(tag_name: ‘img’)

all_images.each do |img|
begin
RestClient.get img.attribute(‘src’) do |response, request, result|
if response.code ==404
puts img.attribute(‘src’)
end
rescue
next img
end
end
end

end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs