ruby - Why do I get invalid attribute error when I pass in a css selector? -


stackoverflow,

here's i'm trying do

def get_element_from_list(root, item, index)   @browser.elements(:css => root).each |element|     if element.present?       return element.element(:css => item, :index => index)     end   end    raise selenium::webdriver::error::nosuchelementerror end  get_element_from_list('div[class*=x-combo-list]', 'x-combo-list-item', index).click 

gives me watir::exception::missingwayoffindingobjectexception: invalid attribute: :css

what don't understand if do

@browser.elements(:css => 'div[class*=x-combo-list]').each |element|   if element.present?     return element.element(:css => 'x-combo-list-item', :index => index)   end end 

basically replacing root , item actual strings works without error.

i think there might bug prevents locating elements :css , :index locator - issue 241.

you can work around issue getting element collection , getting element @ specific index:

return element.elements(:css => 'x-combo-list-item')[index] 

(note think css-selector might wrong. meant .x-combo-list-item.)

alternatively, assuming x-combo-list-item element's class, do:

return element.element(:class => 'x-combo-list-item', :index => index) 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -