UpdatePicPage.java
2.11 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.essa.pageObject.GoodsManage;
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;
/**
* @author Administrator
*更新图片
*/
public class UpdatePicPage extends BasePage {
public UpdatePicPage(WebDriver driver) {
super(driver);
}
public static String picPath;
/*
* 元素定位
*/
//检查点
@FindBy(xpath="//*[text()='SPU信息']")
WebElement checkPoint;
//spu上传图片按钮
@FindBy(xpath="//*[@id='spuWrapper']/div[3]/div[2]")
WebElement spuUploadPic;
//spu的主图
@FindBy(xpath="//*[@class='load-pic']")
WebElement spuPic;
//sku上传图片按钮
@FindBy(xpath="//*[@id='skuWrapper']/div/div/div[1]/div[2]")
WebElement skuUploadPic;
//SKU图片上的X
@FindBy(xpath="//*[contains(@ng-click,'picInfo,')]")
WebElement skuPic;
//保存按钮
@FindBy(xpath="//*[text()='保存']")
WebElement save;
//保存成功提示
@FindBy(xpath="保存成功")
WebElement succeedMessage;
/*
* 以下为页面方法
*/
/**
* 更新商品图片
* @param picPath 作为商品图片的本机地址
* @return GoodsRelesePage
*/
public GoodsRelesePage upDatePic() {
forceWait(2000);
dynamicWait(By.xpath("//*[text()='SPU信息']"));
click(spuUploadPic);
uploadFile(picPath);
//如果spu图片还在上传,则等待2秒
/*while(!isElementExist(spuPic)) {
forceWait(2000);
}*/
dynamicWait(By.xpath("//*[@class='load-pic']"));
click(skuUploadPic);
uploadFile(picPath);
//如果默认的sku图片还存在,说明图片还在上传,继续等待
/*while (!isElementExist(skuPic)) {
forceWait(2000);
}*/
dynamicWait(By.xpath("//*[contains(@ng-click,'picInfo,')]"));
forceWait(1000);
click(save);
return new GoodsRelesePage(driver);
}
/**
* 断言更新图片是否成功
* @return
*/
public boolean isSucceed() {
return isElementExist(succeedMessage);
}
/**
* 通过GUI设置本机图片路径
* @param picpath
*/
public static void setPicPath(String picpath) {
picPath = picpath;
}
}