点击 img 水豚
click on img capybara
Git本页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
不知道为什么我可以点击此页面上的每个项目或 link 除了这块 img。 (使用闹鬼)
不需要找到元素,实际上点击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
Git本页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
不知道为什么我可以点击此页面上的每个项目或 link 除了这块 img。 (使用闹鬼)
不需要找到元素,实际上点击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