On Github nizsheanez / lzd-acceptance-patterns
Author - Alex Sharov
https://svn.rocket-internet.de/svn/SHOP/cucumber_save/profiles/lazada/step_definitions/checkout.rb
find(:css, '#tab_IPay88_option').click # This sleep is necessary due o new 3 step checkout cart # When we change netween payment methods, min-cart does a ajax update # And if we try to proceed to checkout when mini cart is till updating # A error message appears, so we need to wait a little for it, sleep 5
#go to each product line in page for i in 1..product_group.length product_in_group = page.all(:xpath, "//*[@id='productsCatalog']/li[#{i}]/ul/li") #go to each product on product line for j in 1..product_in_group.length #select random product in product group find(:xpath, "//*[@id='productsCatalog']/li[#{i}]/ul/li[#{j}]/*/a").click stock_hint = product_has_stock() #If product has stock add to cart and stop loop if stock_hint click_button('AddToCart') items_added +=1 if items_added == items.to_i break else visit path_to "/all-products/?price=#{Fixtures.instance['price range']}&sort=priceasc&dir=asc&page=#{@page}" end #if product does not has stock, go back all product page and choose another product else visit path_to "/all-products/?price=#{Fixtures.instance['price range']}&sort=priceasc&dir=asc&page=#{@page}" end end end
Scenario: Register new user When I click on login button Then I should see login overlay When I click on new user button And I enter new user information Then I should be logged in When I click on logout button Then I should be logged out When I go to the homepage When I click on login button Then I should see login overlay And I reuse new user credentials Then I should be logged in
Split: "logic of UI" and "logic of App" Then on change markup your tests will possible to repair in one place: class which contains "logic of UI"
https://svn.rocket-internet.de/svn/SHOP/cucumber_save/profiles/lazada/step_definitions/cart.rb
#select random product in product group using_wait_time 10 do find(:xpath, "//*[@id='productsCatalog']/li[#{random_product_group.to_s}]/ul/li[#{random_product_in_group.to_s}]/div/a[contains(@class,'itm-link')]/span[@class='itm-productInfo']").click end
https://svn.rocket-internet.de/svn/SHOP/cucumber_save/profiles/lazada/step_definitions/homepage.rb
when 'MY' find(:xpath,"//li/a[contains(@href,'order-tracking')]").click when 'PH' find(:xpath,"//li/a[contains(@href,'orderstatus')]").click when 'ID' find(:xpath,"//li/a[contains(@href,'order-status')]").click when 'TH' find(:xpath,"//li/a[contains(@href,'order-tracking')]").click when 'VN' find(:xpath,"//li/a[contains(@href,'kiem-tra-don-hang')]").click end
They are more stable than markup, just need sometimes to kick markup-guys
Just create global object and put there all client errors, after test get it and check.
Author - Alex Sharov