def add_adset(custom_ad_source)
  begin
    element_present(:xpath,".//*[@id='adSetDetailsBody']/div[3]/button","Unable to add another ad")
    click_element(:xpath,".//*[@id='adSetDetailsBody']/div[3]/button","Unable to add another ad")
    wait_until(20)
    #WAIT.until {$driver.find_element(:xpath,".//*[@id='adSetDetailsBody']/div[3]")}
    assign_ad_source(custom_ad_source)
    puts"error 1"
    sleep 4
  rescue Exception => e
    STDERR.puts e.message
  end
end

Add a code snippet to your website: www.paste.org