Commit 0e4d02cb24161b0953fa097446c7f468312f177b
1 parent
a90375bd
增加装柜任务形成现存尾货
Showing
6 changed files
with
200 additions
and
3 deletions
Show diff stats
src/main/java/com/essa/framework/BasePage.java
@@ -74,7 +74,6 @@ public class BasePage { | @@ -74,7 +74,6 @@ public class BasePage { | ||
74 | } catch (Exception e) { | 74 | } catch (Exception e) { |
75 | Logger.Output(LogType.LogTypeName.ERROR, element.toString()+"元素不存在"); | 75 | Logger.Output(LogType.LogTypeName.ERROR, element.toString()+"元素不存在"); |
76 | } | 76 | } |
77 | - | ||
78 | } | 77 | } |
79 | 78 | ||
80 | /** | 79 | /** |
@@ -483,7 +482,24 @@ public class BasePage { | @@ -483,7 +482,24 @@ public class BasePage { | ||
483 | Logger.Output(LogType.LogTypeName.INFO, "返回切片后的字符串"); | 482 | Logger.Output(LogType.LogTypeName.INFO, "返回切片后的字符串"); |
484 | return search_need; | 483 | return search_need; |
485 | } | 484 | } |
486 | - | 485 | + |
486 | + /** | ||
487 | + * 字符串切片 | ||
488 | + * @param element 需要被操作的元素 | ||
489 | + * @param begin 从这个字符开始切 | ||
490 | + * @param end 到这个字符结尾 | ||
491 | + * @return | ||
492 | + */ | ||
493 | + protected String partiaStr(WebElement element,int begin,int end){ | ||
494 | + String Str = element.getText(); | ||
495 | + System.out.print("获取所需切片的字符串:"); | ||
496 | + // 对字符串切片,保留begin之后,end之前的字符串 | ||
497 | + System.out.println(Str.subSequence(begin,end)); | ||
498 | + // 把切片值作为结果并返回 | ||
499 | + String search_need = (String) Str.subSequence(begin,end); | ||
500 | + return search_need; | ||
501 | + } | ||
502 | + | ||
487 | /** | 503 | /** |
488 | * 复写切片,仅在本页面作为截断日志文本后面带的一堆字符串 | 504 | * 复写切片,仅在本页面作为截断日志文本后面带的一堆字符串 |
489 | * @param string | 505 | * @param string |
@@ -494,7 +510,7 @@ public class BasePage { | @@ -494,7 +510,7 @@ public class BasePage { | ||
494 | String st1 = string.split(begin)[1]; | 510 | String st1 = string.split(begin)[1]; |
495 | return st1; | 511 | return st1; |
496 | } | 512 | } |
497 | - | 513 | + |
498 | /**要的元素是否存在,最多5秒 | 514 | /**要的元素是否存在,最多5秒 |
499 | * @param element | 515 | * @param element |
500 | */ | 516 | */ |
src/main/java/com/essa/pageObject/HomePage.java
1 | package com.essa.pageObject; | 1 | package com.essa.pageObject; |
2 | 2 | ||
3 | import com.essa.pageObject.DocumentaryManage.POBoardPage; | 3 | import com.essa.pageObject.DocumentaryManage.POBoardPage; |
4 | +import org.openqa.selenium.By; | ||
4 | import org.openqa.selenium.WebDriver; | 5 | import org.openqa.selenium.WebDriver; |
5 | import org.openqa.selenium.WebElement; | 6 | import org.openqa.selenium.WebElement; |
6 | import org.openqa.selenium.support.FindBy; | 7 | import org.openqa.selenium.support.FindBy; |
@@ -175,6 +176,10 @@ public class HomePage extends BasePage{ | @@ -175,6 +176,10 @@ public class HomePage extends BasePage{ | ||
175 | @FindBy (xpath = "//a[contains(text(),'收货任务管理')]") | 176 | @FindBy (xpath = "//a[contains(text(),'收货任务管理')]") |
176 | WebElement goodsReceiveTask; | 177 | WebElement goodsReceiveTask; |
177 | 178 | ||
179 | + //装柜任务管理 | ||
180 | + @FindBy (xpath = "//a[@name='child.text'][contains(text(),'装柜任务管理')]") | ||
181 | + WebElement loadContainerTask; | ||
182 | + | ||
178 | /* | 183 | /* |
179 | * 方法 | 184 | * 方法 |
180 | */ | 185 | */ |
@@ -418,6 +423,18 @@ public class HomePage extends BasePage{ | @@ -418,6 +423,18 @@ public class HomePage extends BasePage{ | ||
418 | } | 423 | } |
419 | 424 | ||
420 | /** | 425 | /** |
426 | + * 进入装柜任务处理管理页面 | ||
427 | + * @return 返回装柜任务处理管理页面 | ||
428 | + */ | ||
429 | + public NeedDealtApplyPage toLoadContainer(){ | ||
430 | + click(StorageManage); | ||
431 | + click(loadContainerTask); | ||
432 | + dynamicWait(By.xpath("//div[@class='loading ng-scope']")); | ||
433 | + forceWait(3000); | ||
434 | + return new NeedDealtApplyPage(driver); | ||
435 | + } | ||
436 | + | ||
437 | + /** | ||
421 | * 登记备选船期待办 | 438 | * 登记备选船期待办 |
422 | * @return 进入登记船务船期待办详情页面 | 439 | * @return 进入登记船务船期待办详情页面 |
423 | */ | 440 | */ |
src/main/java/com/essa/pageObject/StorageManage/LoadContainerHandlePage.java
0 → 100644
@@ -0,0 +1,70 @@ | @@ -0,0 +1,70 @@ | ||
1 | +package com.essa.pageObject.StorageManage; | ||
2 | + | ||
3 | +import com.essa.framework.BasePage; | ||
4 | +import com.essa.framework.Model; | ||
5 | +import org.openqa.selenium.By; | ||
6 | +import org.openqa.selenium.WebDriver; | ||
7 | +import org.openqa.selenium.WebElement; | ||
8 | +import org.openqa.selenium.support.FindBy; | ||
9 | + | ||
10 | +import java.util.Date; | ||
11 | + | ||
12 | + | ||
13 | +/** | ||
14 | + * 装柜任务处理 | ||
15 | + */ | ||
16 | +public class LoadContainerHandlePage extends BasePage { | ||
17 | + | ||
18 | + public LoadContainerHandlePage(WebDriver driver){ | ||
19 | + super(driver); | ||
20 | + } | ||
21 | + | ||
22 | + /** | ||
23 | + * 元素定位 | ||
24 | + */ | ||
25 | + // 实装柜日期 | ||
26 | + @FindBy (xpath = "//input[@id='loadCompleteDate']") | ||
27 | + WebElement actLoadTime; | ||
28 | + | ||
29 | + // 可装柜箱数 | ||
30 | + @FindBy (xpath = "//tr[@class='ng-scope']//td[6]") | ||
31 | + WebElement mayLoadQuantity; | ||
32 | + | ||
33 | + // 实装箱数 | ||
34 | + @FindBy (xpath = "//input[@id='actLoadBoxQuantity']") | ||
35 | + WebElement actLoadQuantity; | ||
36 | + | ||
37 | + // 点击选择文件 | ||
38 | + @FindBy (xpath ="//div[@id='rt_rt_1cqvbp0jn14kfb41keb187l1u8oh']//label" ) | ||
39 | + WebElement actPicture; | ||
40 | + | ||
41 | + // 提交 | ||
42 | + @FindBy (xpath = "//*[text()='提交']") | ||
43 | + WebElement submit; | ||
44 | + | ||
45 | + /** | ||
46 | + * 页面方法 | ||
47 | + */ | ||
48 | + public LoadContainerHandlePage loadTaskHandle(){ | ||
49 | + jsExecutorRemoveAttribute(actLoadTime,"readonly"); | ||
50 | + String date = getDateTimeByFormat(new Date(), "MM/dd/yyyy"); | ||
51 | + sendKeys(actLoadTime,date); | ||
52 | + // 获取‘可装柜数量’字符串中的数量 | ||
53 | + String qua = partiaStr(mayLoadQuantity,0,1); | ||
54 | + // 对切片结果进行int转换 | ||
55 | + int i = Integer.valueOf(qua).intValue(); | ||
56 | + // 形成现存尾货‘2’ | ||
57 | + int j = i-2; | ||
58 | + // 对计算结果转换成string,并赋值给“实装柜数量” | ||
59 | + String quantity = String.valueOf(j); | ||
60 | + sendKeys(actLoadQuantity,quantity); | ||
61 | + forceWait(1000); | ||
62 | + // 上传装柜图片 | ||
63 | + click(actPicture); | ||
64 | + uploadFile(Model.getPicPath()); | ||
65 | + forceWait(1000); | ||
66 | + click(submit); | ||
67 | + forceWait(2000); | ||
68 | + return new LoadContainerHandlePage(driver); | ||
69 | + } | ||
70 | +} |
src/main/java/com/essa/pageObject/StorageManage/LoadContainerManagePage.java
0 → 100644
@@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
1 | +package com.essa.pageObject.StorageManage; | ||
2 | + | ||
3 | +import com.essa.framework.BasePage; | ||
4 | +import com.essa.framework.Model; | ||
5 | +import net.bytebuddy.asm.Advice; | ||
6 | +import org.openqa.selenium.WebDriver; | ||
7 | +import org.openqa.selenium.WebElement; | ||
8 | +import org.openqa.selenium.support.FindBy; | ||
9 | + | ||
10 | +public class LoadContainerManagePage extends BasePage { | ||
11 | + | ||
12 | + public LoadContainerManagePage(WebDriver driver) { | ||
13 | + super(driver); | ||
14 | + } | ||
15 | + | ||
16 | + /** | ||
17 | + * 元素定位 | ||
18 | + */ | ||
19 | + | ||
20 | + // 关键字搜索输入框 | ||
21 | + @FindBy(xpath = "//input[@placeholder='请输入PO单号或采购商编号,多个请用空格隔开']") | ||
22 | + WebElement inputKeySearch; | ||
23 | + | ||
24 | + // 放大镜搜索按钮 | ||
25 | + @FindBy(xpath = "//*[@class='iconfont icon-search']") | ||
26 | + WebElement keySearch; | ||
27 | + | ||
28 | + // 选中查询的第一条数据 | ||
29 | + @FindBy (xpath = "//td[@title='待处理']") | ||
30 | + WebElement firstPO; | ||
31 | + | ||
32 | + // 处理 | ||
33 | + @FindBy(xpath = "//*[text()='处理']") | ||
34 | + WebElement handle; | ||
35 | + | ||
36 | + /** | ||
37 | + * 页面方法 | ||
38 | + * | ||
39 | + * @return | ||
40 | + */ | ||
41 | + public LoadContainerManagePage toLoadContainerDetail() { | ||
42 | + sendKeys(inputKeySearch, Model.getPoNum()); | ||
43 | + forceWait(5000); | ||
44 | + click(keySearch); | ||
45 | + forceWait(2000); | ||
46 | + click(firstPO); | ||
47 | + forceWait(2000); | ||
48 | + click(handle); | ||
49 | + return new LoadContainerManagePage(driver); | ||
50 | + } | ||
51 | +} |
src/main/java/com/essa/testSuite/TestLoadContainerTask.java
0 → 100644
@@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
1 | +package com.essa.testSuite; | ||
2 | + | ||
3 | +import com.essa.pageObject.BaseTest; | ||
4 | +import com.essa.pageObject.HomePage; | ||
5 | +import com.essa.pageObject.StorageManage.LoadContainerHandlePage; | ||
6 | +import com.essa.pageObject.StorageManage.LoadContainerManagePage; | ||
7 | +import org.openqa.selenium.WebDriver; | ||
8 | +import org.openqa.selenium.support.PageFactory; | ||
9 | +import org.testng.annotations.AfterClass; | ||
10 | +import org.testng.annotations.BeforeClass; | ||
11 | +import org.testng.annotations.Test; | ||
12 | + | ||
13 | +public class TestLoadContainerTask extends BaseTest { | ||
14 | + | ||
15 | + WebDriver driver; | ||
16 | + | ||
17 | + @BeforeClass | ||
18 | + public void setUp(){ | ||
19 | + initsetUp(); | ||
20 | + loginValid("chenyijie"); | ||
21 | + } | ||
22 | + | ||
23 | + @AfterClass | ||
24 | + public void tearDown(){ | ||
25 | + driver.quit(); | ||
26 | + } | ||
27 | + | ||
28 | + /** | ||
29 | + * 装柜任务处理 | ||
30 | + */ | ||
31 | + @Test(description="装柜任务处理") | ||
32 | + public void LoadContainerTask() { | ||
33 | + this.driver = getDriver(); | ||
34 | + HomePage homePage = PageFactory.initElements(driver,HomePage.class); | ||
35 | + homePage.toLoadContainer(); | ||
36 | + LoadContainerManagePage loadContainerManagePage = PageFactory.initElements(driver,LoadContainerManagePage.class); | ||
37 | + loadContainerManagePage.toLoadContainerDetail(); | ||
38 | + LoadContainerHandlePage loadContainerHandlePage = PageFactory.initElements(driver,LoadContainerHandlePage.class); | ||
39 | + loadContainerHandlePage.loadTaskHandle(); | ||
40 | + homePage.logout(); | ||
41 | + } | ||
42 | +} |
src/main/java/com/essa/testSuite/TestNoticeReceiveAndLoad.java
@@ -55,6 +55,7 @@ public class TestNoticeReceiveAndLoad extends BaseTest{ | @@ -55,6 +55,7 @@ public class TestNoticeReceiveAndLoad extends BaseTest{ | ||
55 | SoftAssert anAssert = new SoftAssert(); | 55 | SoftAssert anAssert = new SoftAssert(); |
56 | anAssert.assertEquals(actualLoae,true,"通知装柜失败!"); | 56 | anAssert.assertEquals(actualLoae,true,"通知装柜失败!"); |
57 | anAssert.assertAll(); | 57 | anAssert.assertAll(); |
58 | + homePage.logout(); | ||
58 | } | 59 | } |
59 | 60 | ||
60 | } | 61 | } |