2016-10-02 7 views
0

このページをhttps://ru.aliexpress.com/store/product/Original-xiaomi-Redmi-note3-snapdragon-650-4000mAh-13ML-1080P-3G-32G-5-5-screen-octa-core/1986585_32622877163.html?detailNewVersion=&categoryId=5090301 と私は思うように各色の変更をクリックする必要があります。すべての設定とドライバは、ページ上の他の要素と相互作用できます。img capybaraをクリックして

page.all(:css, '.item-sku-image img').each_with_index do |mod,i| 

     find(:xpath,"//img[@title='#{mod['title']}']").find(:xpath, "..").click 

     puts find(:xpath,"//img[@title='#{mod['title']}']").find(:xpath, "..").find(:xpath, "..")['class'] # with this line i'm checkin` if i clicked on img block cuz his parend node changes it's class to active 
    end 

コードは、なぜ私はIMGのこのブロックを除いて、このページのすべての単一の項目またはリンクをクリックすることができます見当がつかない。 (ポルターガイストを使用して)

答えて

0

要素をリファインする必要はありません。実際、img要素自体をクリックすると完全にうまくいくはずです。

page.all(:css, '.item-sku-image img').each_with_index do |mod,i| 
    mod.click # mod.find(:xpath, "./..").click if you do need to click the parent 
    puts mod.find(:xpath, "./ancestor::li").matches_selector?(:css, '.active') 
end 
関連する問題