SupplierStrengthPage.java
10 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
package com.essa.pageObject.SupplierManage;
import java.util.List;
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;
/*
* @Description:综合实力评估页面
* @Author: ZengJin
* @CreateTime: 2018/10/29
*/
public class SupplierStrengthPage extends BasePage{
public SupplierStrengthPage(WebDriver driver) {
super(driver);
}
/*
* 元素定位
*/
//配合度
@FindBy (xpath="//*[contains(text(),'配合度')]/../div[1]/div/select")
WebElement cooperateDegree;
//主打产品定位
@FindBy (xpath="//*[@dict-check-list='supplier_main_product_location']/select")
WebElement mainProduct;
//是否有研发能力:否
@FindBy (xpath = "//*[contains(text(),'是否有研发能力')]/../div/label[2]")
WebElement notDev;
//是否研发能力:是
@FindBy (xpath = "//*[contains(text(),'是否有研发能力')]/../div/label[1]")
WebElement isDev;
//每个季度有新品推出
@FindBy (xpath = ".//*[@class='col-md-20']/div/label[1]/input")
WebElement newGoodsEveryQuarter;
//有配备工程师
@FindBy (xpath =".//*[@class='col-md-20']/div/label[2]/input")
WebElement existsEngineer;
//有产品研发团队
@FindBy (xpath = ".//*[@class='col-md-20']/div/label[3]/input")
WebElement existsProductDev;
//其他
@FindBy (xpath = ".//*[@class='col-md-20']/div/label[4]/input")
WebElement others;
//其他文本输入框
@FindBy (xpath = ".//*[@ng-model='ctrl.model.otherDevelopmentAbilityValue']")
WebElement otherDevAbilValue;
//是否有证书:是
@FindBy (xpath = ".//*[contains(text(),'是否有证书')]/../div/label[1]")
WebElement isCertificate;
//是否有证书:否
@FindBy (xpath =".//*[contains(text(),'是否有证书')]/../div/label[2]")
WebElement notCertificate;
//添加证书的“+”
@FindBy (xpath = ".//*[@list='ctrl.model.supplierCertificationList']/div[1]/div/button[1]")
WebElement addCertificate;
/*
* 由于这个是动态表格,表格行数会变化,必须自己写方法来定位元素
* 证书类型选择项,value值:0~8 0:BSCI,1:SA8000,2:ICTT……
*/
public WebElement itemType(int i) {
String xpath = ".//*[@list='ctrl.model.supplierCertificationList']/div[1]/table/tbody/tr["+i+"]/td[2]/div/select";
return driver.findElement(By.xpath(xpath));
}
//证书编号文本框
public WebElement itemCode(int i) {
String xpath = ".//*[@list='ctrl.model.supplierCertificationList']/div[1]/table/tbody/tr["+i+"]/td[3]/input";
return driver.findElement(By.xpath(xpath));
}
//证书说明文本框
public WebElement itemDec(int i) {
String xpath = ".//*[@list='ctrl.model.supplierCertificationList']/div[1]/table/tbody/tr["+i+"]/td[4]/input";
return driver.findElement(By.xpath(xpath));
}
//证书图片,用于判断图片是否上传成功
public WebElement imge(int i) {
String xpath = ".//*[@list='ctrl.model.supplierCertificationList']/div[2]/div[2]/div/div["+i+"]/div[1]/img";
return driver.findElement(By.xpath(xpath));
}
//添加证书文件
public WebElement itemFile(int i) {
String xpath = ".//*[@list='ctrl.model.supplierCertificationList']/div[2]/div[2]/div/div["+i+"]/div[4]";
return driver.findElement(By.xpath(xpath));
}
//已添加证书下的证书集合
@FindBy (xpath = ".//*[@list='ctrl.model.supplierCertificationList']/div[1]/table/tbody/tr")
List<WebElement> checkBoxes;
//是否服务过大客户:是
@FindBy (xpath = ".//*[contains(text(),'是否服务过大客户')]/../div[1]/label[1]")
WebElement isServLargeCus;
//是否服务过大客户:否
@FindBy (xpath = ".//*[contains(text(),'是否服务过大客户')]/../div[1]/label[2]")
WebElement notServLargeCus;
//服务过的大客户数
@FindBy (xpath = ".//*[@list='ctrl.model.serviceLargeCustomerList']/div/table/tbody/tr")
List<WebElement> customers;
//大客户的“+”
@FindBy (xpath = ".//*[@list='ctrl.model.serviceLargeCustomerList']/div/div/button[1]")
WebElement addCustomer;
//大客户名称文本框
public WebElement largeCusName(int i) {
String xpath = ".//*[@list='ctrl.model.serviceLargeCustomerList']/div/table/tbody/tr["+i+"]/td[2]/input";
return driver.findElement(By.xpath(xpath));
}
//备注文本框
public WebElement note(int i) {
String xpath = ".//*[@list='ctrl.model.serviceLargeCustomerList']/div/table/tbody/tr["+i+"]/td[3]/input";
return driver.findElement(By.xpath(xpath));
}
//确定按钮
@FindBy (xpath = "//*[text()='确定']")
WebElement submit;
//标签页名称
@FindBy (xpath ="//*/a[contains(text(),'综合实力评估')]")
WebElement labelName;
//提交完成后,操作成功的弹框关闭按钮
@FindBy (xpath="//*[@class='close']")
WebElement alertClosed;
//关闭页面
@FindBy(xpath = "//*[text()='综合实力评估']/../span")
WebElement closed;
/*
* 方法
*/
//选择配合度
public void selectCooperateDegree(String cooperateGrade) {
//选择配合度:高、中、低
selectElement(cooperateDegree, cooperateGrade);
}
//是否有研发能力,参数可选 是/否
public void isDevAblity(String ablity) {
if("是".equals(ablity))
click(isDev);
else {
click(notDev);
}
}
//
//提交编辑
public void submit() {
moveHeightScroll("0");
click(submit);
}
//勾选每季度有新品推出
public void newProduct() {
if(newGoodsEveryQuarter.isSelected());//判断是否已勾选
else {
isElementExist(newGoodsEveryQuarter);
click(newGoodsEveryQuarter);
}
}
//勾选有配备工程师
public void haveEngineer() {
if(existsEngineer.isSelected());
else {
isElementExist(existsEngineer);
click(existsEngineer);
}
}
//勾选有研发团队
public void haveTeam() {
if (existsProductDev.isSelected());
else {
isElementExist(existsProductDev);
click(existsProductDev);
}
}
//勾选“其他”
public void other() {
if(others.isSelected());
else {
click(others);
isElementExist(otherDevAbilValue);
sendKeys(otherDevAbilValue, "我们每天都有新品推出!");
}
}
//拖动滚动条,因为本页面如果数据量多,就看不到头部的关闭本页面的X
public void moveScroll() {
moveHeightScroll("100");
}
//检查是否列表加载完成
public boolean isSucceed() throws InterruptedException {
while(!(labelName.isDisplayed())) {
Thread.sleep(1000);
}
return isElementExist(labelName);
}
//判断是否提交成功
public boolean isSubmit() {
return isElementExist(alertClosed);
}
//关闭“操作成功”提示
public void alertClosed() {
click(alertClosed);
}
/*
* 添加证书逻辑:
* 1.点击是否有证书:是
* 2.点击“+”
* 3.统计已有x个证书
* 4.i=x
* 5.选择证书类型WRAP,证书编号,证书说明,传证书图片
* 6.判断证书是否上传成功,不成功则等待
*/
public void addCertification() throws Exception {
click(isCertificate);
isElementExist(addCertificate);
click(addCertificate);
List<WebElement> list= checkBoxes;
int x = list.size();
selectElement(itemType(x), "WRAP");
sendKeys(itemCode(x), "20180331:"+x);
sendKeys(itemDec(x), "证书说明:这是第"+x+"个证书");
click(itemFile(x));
uploadFile("E:\\pic\\证书.jpg");
//如果图片是系统默认的图片,则等待1秒
while("/img/nopic.jpg".equals(imge(x).getAttribute("ng-src"))) {
Thread.sleep(1000);
}
}
/*
* 添加服务大客户记录
* 先把滚动条拉下来,不然找不到元素
* 1.是否服务过大客户,点击:是
* 2.点击“+”
* 3.判断已有服务过的次数x,i=x
* 4.写入大客户名称,备注
*/
public void addSerLargeCus() {
moveHeightScroll("0");
click(isServLargeCus);
isElementExist(addCustomer);
click(addCustomer);
List<WebElement> list = customers;
int x = list.size();
sendKeys(largeCusName(x), "第"+x+"大客户");
sendKeys(note(x), "这个是备注信息"+x);
}
//选择主打产品
public void selMainProduct(String degree) {
selectElement(mainProduct, degree);
}
//关闭本页面
public void closed() {
click(closed);
}
}