Skip to content

Commit

Permalink
Update Product Page
Browse files Browse the repository at this point in the history
  • Loading branch information
sayems committed Sep 23, 2016
1 parent 5f83413 commit 39f17e2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion selenium/pages/category_page.go
Expand Up @@ -13,7 +13,7 @@ type CategoryPage struct {
Page Page
}

func (s *CategoryPage) AddProduct() *ProductPage{
func (s *CategoryPage) SelectProduct() *ProductPage{
productList := s.Page.FindElementsByCss(listOfProduct)
productList[rand.Intn(len(productList))].Click()
time.Sleep(time.Millisecond * 5000)
Expand Down
2 changes: 1 addition & 1 deletion selenium/pages/home_page.go
Expand Up @@ -12,7 +12,7 @@ var (
account = "#header > div > div:nth-of-type(2) > a:nth-of-type(3) > span:nth-of-type(2)"
myAccount = "#header-account > div > ul > li:nth-of-type(1) > a"
womenTab = "#nav > ol > li:nth-of-type(1) > a"
viewAllWomen = "#nav > ol > li:nth-of-type(1) > ul > li:nth-of-type(1) > aa"
viewAllWomen = "#nav > ol > li:nth-of-type(1) > ul > li:nth-of-type(1) > a"

)

Expand Down
20 changes: 18 additions & 2 deletions selenium/pages/product_page.go
@@ -1,11 +1,27 @@
package pages

import "time"

type ProductPage struct {
Page Page
}

func (s *ProductPage) addToCart() *CheckoutPage {

var (
color = "#attribute92"
colorOption = "#attribute92 > option:nth-of-type(2)"
size = "#attribute180"
sizeOption = "#attribute180 > option:nth-of-type(2)"
addToCartBtn = ".button.btn-cart"
)

func (s *ProductPage) AddProductToCart() *CheckoutPage {

s.Page.FindElementByCss(color).Click()
s.Page.FindElementByCss(colorOption).Click()
s.Page.FindElementByCss(size).Click()
s.Page.FindElementByCss(sizeOption).Click()
s.Page.FindElementByCss(addToCartBtn).Click()
time.Sleep(time.Millisecond * 5000)
return &CheckoutPage{Page:s.Page}
}

Expand Down
2 changes: 1 addition & 1 deletion selenium/pages/women_page.go
Expand Up @@ -8,7 +8,7 @@ var (
pantsAndDenium = ".catblocks>li:nth-of-type(3)>a"
)

func (s *WomenPage) SelectPantsAndDenim() *CategoryPage {
func (s *WomenPage) SelectCategory() *CategoryPage {
s.Page.FindElementByCss(pantsAndDenium).Click()
return &CategoryPage{Page:s.Page}
}
Expand Down
5 changes: 3 additions & 2 deletions selenium/tests/women_test.go
Expand Up @@ -9,7 +9,8 @@ func TestWomenPage(t *testing.T) {

login := pages.HomePage{Page:page}
login.GoToWomenPage().
SelectPantsAndDenim().
AddProduct()
SelectCategory().
SelectProduct().
AddProductToCart()

}

0 comments on commit 39f17e2

Please sign in to comment.