BillingCenterPage.java
5.02 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
package com.essa.pageObject.DocumentaryManage;
import com.essa.framework.BasePage;
import com.essa.framework.Model;
import com.essa.pageObject.HomePage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.testng.asserts.SoftAssert;
/**
* @Description: 发单中心页面
* @Author: ZengJin
* @CreateTime: 2018/10/31
*/
public class BillingCenterPage extends BasePage {
/**
* 构造方法
*
* @param driver
*/
public BillingCenterPage(WebDriver driver) {
super(driver);
}
/**
* 元素定位
*/
@FindBy (xpath = "//*[@ng-model='query.params.keyword']")
WebElement keyword;//关键字搜索框
@FindBy (xpath = "//*[text()='高级查询']")
WebElement advancedSearch;//高级查询
@FindBy (xpath = "//*[@ng-model='query.params.poCode']")
WebElement PONum;//根据PO单号查询
@FindBy (xpath = "//*[@ng-click='richSearch()']")
WebElement search;//高级查询:查询按钮
@FindBy (xpath = "//*[text()='开始发单']")
WebElement send;//开始发单按钮
@FindBy (xpath = "//*[text()='登记接单']")
WebElement accept;//登记接单按钮
@FindBy (xpath = "//tbody//tr[1]/td[1]")
WebElement firstFo;//第一个FO单编号
@FindBy (xpath = "//tbody//tr[1]/td[3]")
WebElement status;//第一个FO单发单状态
@FindBy (xpath = "//*[@ng-model='scanValue']")
WebElement FOKeyword;//弹框里的FO单号查询输入框
@FindBy (xpath = "//*[@ng-click='clickBtn()']")
WebElement FOSearch;//FO查询搜索框
@FindBy (xpath = "//*[@ng-click='sendBill()']")
WebElement sendBill;//开始发单按钮
@FindBy (xpath = "//*[@ng-click='acceptBill()']")
WebElement acceptBill;//接单完成
@FindBy (xpath = "//div[@class='left ng-scope']//span[2]")
WebElement total;//一共有多少个FO单
@FindBy (xpath = "//button[contains(text(),'50')]")
WebElement show50;//分页展示50个
/**
* 页面方法
*/
/**
*单个Fo单的发单方法
* @param
* @return homePage
*/
public HomePage Billing(){
forceWait(2000);
sendKeys(keyword,"程序仍在进行,等待页面加载完成中……");
forceWait(4000);
dynamicLoad(By.xpath("//*[text()='对不起!没有查询到相关数据。']"));
clear(keyword);
click(advancedSearch);
sendKeys(PONum,Model.getPoNum());
click(search);
dynamicLoad();
String FO = firstFo.getText();
click(send);
sendKeys(FOKeyword,FO);
click(FOSearch);
forceWait(500);
click(sendBill);
forceWait(500);
SoftAssert softAssert = new SoftAssert();
softAssert.assertEquals(status.getText(),"发单中","发单失败!");
click(accept);
sendKeys(FOKeyword,FO);
click(FOSearch);
forceWait(500);
click(acceptBill);
forceWait(500);
softAssert.assertEquals(status.getText(),"已接单","接单失败!");
softAssert.assertAll();
return new HomePage(driver);
}
/**
*多个FO单时的发单
* @param
* @return
*/
public HomePage MoreBilling(){
forceWait(2000);
sendKeys(keyword,"程序仍在进行,等待页面加载完成中……");
forceWait(4000);
dynamicLoad(By.xpath("//*[text()='对不起!没有查询到相关数据。']"));
clear(keyword);
click(advancedSearch);
sendKeys(PONum,Model.getPoNum());
click(search);
dynamicLoad();
int totalNum = Integer.parseInt(total.getText());//根据分页获取FO单总数
if (totalNum>10){
click(show50);
forceWait(1000);
}
for(int i=1;i<=totalNum;i++){
WebElement FOs = driver.findElement(By.xpath("//tbody//tr["+i+"]/td[1]"));//获取Fo单号
WebElement FoStatus = driver.findElement(By.xpath("//tbody//tr["+i+"]/td[3]"));//当前FO单状态
String FO = FOs.getText();
switch (FoStatus.getText()){
case "制单中" :
click(send);
sendKeys(FOKeyword,FO);
click(FOSearch);
forceWait(500);
click(sendBill);
forceWait(500);
click(accept);
sendKeys(FOKeyword,FO);
click(FOSearch);
forceWait(500);
click(acceptBill);
forceWait(500);
break;
case "发单中" :
click(accept);
sendKeys(FOKeyword,FO);
click(FOSearch);
forceWait(500);
click(acceptBill);
forceWait(500);
break;
default :
break;
}
}
return new HomePage(driver);
}
}