Blame view

src/test/java/com/buyer/pageObject/ShoppingCartPage.java 1.67 KB
c98c375e   Administrator   all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  package com.buyer.pageObject;

  

  import org.openqa.selenium.By;

  import org.openqa.selenium.WebDriver;

  import org.openqa.selenium.WebElement;

  import org.openqa.selenium.support.FindBy;

  

  import com.essa.framework.BasePage;

  import com.essa.framework.Model;

  

  /**

   * 购物车页

   * @author Administrator

   *

   */

  public class ShoppingCartPage extends BasePage {

  	public ShoppingCartPage(WebDriver driver) {

  		super(driver);

  	}

  	/*

  	 * 元素定位

  	 */

  	//关键字查询框

  	@FindBy (xpath ="//*[@ng-model='keyword']")

  	WebElement keyword;

  	

  	//查询按钮

  	@FindBy (xpath ="//*[contains(@ng-click,'search()')]")

  	WebElement searchButton;

  	

  	//搜索结果的一个sku对应的复选框

  	@FindBy (xpath ="//*[contains(@class,'products-list ng-scope')]/div[2]/div[2]/span[1]/input")

  	WebElement checkbox;

  	

  	//可拼柜

  	@FindBy (xpath="//*[text()='Consolidation allowed']")

  	WebElement consolidationAllowed;

  	

  	//开始拼柜

  	@FindBy (xpath ="//button[contains(text(),' Start consolidation')]")

  	WebElement startConslidation;

  	

  	/*

  	 * 页面方法

  	 */

  	/**

  	 * 断言sku是否已经加入购物车

  	 * @return true:已加入 false:未加入

  	 */

  	public boolean isSucceed() {

  		mywait(keyword);

  		sendKeys(keyword, Model.getSkuNo());

  		click(searchButton);

  		mywait(checkbox);

  		forceWait(2000);

  		return isVisibility(By.xpath("//*[contains(text(),'"+Model.getSkuNo()+"')]"));

  	}

  	/**

  	 * 开始拼柜

  	 * @return ConslidationPage

  	 */

  	public ConslidationPage startConslidation() {

  		mywait(keyword);

  		click(consolidationAllowed);

  		mywait(startConslidation);

  		click(startConslidation);

  		return new ConslidationPage(driver);

  	}

  	

  }