From: Hassan Schroeder Date: 2012-12-13T05:24:00+09:00 Subject: Re: Find element test with webdriver On Wed, Dec 12, 2012 at 11:51 AM, Mattias A. wrote: > Your array tips dosent work when the element not exists or i maybe I do > something wrong? Expected output below would be "No", but the test fails > and will not complete the run. It complains about the row array = > @driver.find_element(:id, "gbqfqX") Specifying exactly what that "complaint" is would help people help you, but ... > def by_id_array > array = [] > array = @driver.find_element(:id, "gbqfqX") > puts 'No' if array.size == 0 > end It helps to pay attention to what's actually returned by the method you're calling. Try using this: def by_id begin @driver.find_element(:id, 'gbqfbax') rescue => err puts 'Did not find element with Id: gbqfba' puts "because of #{err} (#{err.class})" end end HTH, -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com http://about.me/hassanschroeder twitter: @hassan