mardi 2 octobre 2018

How to skip an element when iterating through a list Ruby

I have the following script which loops through an element list

    $browser.divs(class:'menu-index-page__menu-category').map do |cat|
  cate = cat.h3.text
  puts cate

  cc = cat.ul(class:'menu-index-page__items')
  cc.lis(class:'menu-index-page__item').each do |lit|
    lit.fire_event :click
    sleep(5)

however once in a while the name of the class list changes to:

menu-index-page__item menu-index-page__item--unavailable

This then breaks the script, I want to be able to skip this whenever is comes up and continue with the orginal script. Any help or pointers in the right direction would be greatly appreciated.

enter image description here

Aucun commentaire:

Enregistrer un commentaire