Git this page 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 我需要点击每个颜色修改。所有的配置和驱动程序工作得很好,因为我可以互动的页面上有其他元素。
代码
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。 (使用poltergeist)
答案 0 :(得分: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