1
Hello!
I am performing the automation of testing a site, using Capybara, Ruby and Cucumber, where it has Lazy Loading, for loading all products.
Problem flow: Home page -> Scroll to the first product -> Add-Ló to cart
What is going on? In the "Scroll to the first product", Because the site has Lazy loading, the products are displaying the loading, however, do not load. This only happens at the time of automation, if manually move the screen a little bit, the products are loaded, thus becoming visible (discarding problems on the site). I made the attempt to simulate my manual scroll, via automation but without success.
Code:
Page Object:
require 'sections/headers/main_header.rb'
require 'sections/siders/side_menu.rb'
require 'sections/login/login.rb'
require 'sections/produto/box_produto.rb'
module ATG
module Pages
module Home
class Home < SitePrism::Page
set_url '/'
section :main_header, ATG::Sections::Headers::MainHeader, 'div[class*="header-main"]'
section :side_menu, ATG::Sections::Siders::SideMenu, 'div[class*="menu-main"]'
section :login, ATG::Sections::Login::Login, 'div[id="modal-login"]'
sections :box_produto, ATG::Sections::Produto::BoxProduto, 'div[class*="box-prod"]'
element :modal_home, 'div[class="modal-close"]'
def close_modal_home
wait_for_modal_home
modal_home.gclick
end
def scroll_produtos
scroll_into_view('.page-content')
sleep 3
end
def scroll_to_first_buyable
scroll_into_view('.box-prod')
end
end
end
end
end
Step Definition
Quando("adicionar produto ao carrinho via home") do
binding.pry
@home.scroll_produtos
@home.box_produto.first.greenify
@box_produto = @home.box_produto.first
@box_produto.add_product
step "vejo as informações do produto"
step "abrir o carrinho"
end
Screenshoots: