Commit 46c086991fdeb9c63d7262da1e2ffd602018329b

Authored by zengjin
2 parents b2af39f8 102bbcff

Merge branch 'dev_test' of http://gitlab.essa.top:88/zengjin/EssaAuto into dev_test

# Conflicts:
#	src/main/java/com/essa/pageObject/HomePage.java
src/main/java/com/essa/framework/BasePage.java
... ... @@ -74,7 +74,6 @@ public class BasePage {
74 74 } catch (Exception e) {
75 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 482 Logger.Output(LogType.LogTypeName.INFO, "返回切片后的字符串");
484 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 505 * @param string
... ... @@ -494,7 +510,7 @@ public class BasePage {
494 510 String st1 = string.split(begin)[1];
495 511 return st1;
496 512 }
497   -
  513 +
498 514 /**要的元素是否存在,最多5秒
499 515 * @param element
500 516 */
... ...
src/main/java/com/essa/pageObject/DocumentaryManage/ReceiptCorePage.java
... ... @@ -14,6 +14,10 @@ public class ReceiptCorePage extends BasePage {
14 14 * 页面元素定位
15 15 * */
16 16  
  17 + @FindBy (xpath = "//*[contains(text(),'对不起!没有查询到相关数据')]")
  18 +
  19 + WebElement Wait ;//等待
  20 +
17 21 @FindBy(xpath = "//i[@class='iconfont icon-double-arrow-right']")
18 22 // @FindBy (xpath = "//*[contains(text(),'高级查询')]")
19 23 WebElement advancedQuery; //高级查询
... ... @@ -88,11 +92,15 @@ public class ReceiptCorePage extends BasePage {
88 92  
89 93  
90 94  
91   - /*
92   - * 页面方法
93   - * */
  95 + /**
  96 + *页面方法
  97 + * 前台发单中心页面
  98 + */
94 99  
95 100 public void BillOrder(String PO_Code) {
  101 +
  102 + dynamicWait(By.xpath("//tbody//tr[1]"));
  103 +
96 104 click(advancedQuery);
97 105 forceWait(1000);
98 106  
... ...
src/main/java/com/essa/pageObject/HomePage.java
... ... @@ -3,6 +3,7 @@ package com.essa.pageObject;
3 3 import com.essa.pageObject.DocumentaryManage.POBoardPage;
4 4 import com.essa.pageObject.DocumentaryManage.ReceiptCorePage;
5 5 import com.essa.pageObject.GoodsManage.*;
  6 +import org.openqa.selenium.By;
6 7 import com.essa.pageObject.SupplierManage.SupplierOperationsTrackPage;
7 8 import com.essa.pageObject.productDev.AddMatterialPage;
8 9 import com.essa.pageObject.productDev.AddProjectPage;
... ... @@ -178,10 +179,16 @@ public class HomePage extends BasePage{
178 179 @FindBy (xpath = "//a[contains(text(),'收货任务管理')]")
179 180 WebElement goodsReceiveTask;
180 181  
  182 +
181 183 //物料新增
182 184 @FindBy (xpath = "//*[text()='物料新增']")
183 185 WebElement addMaterial;
184 186  
  187 + //装柜任务管理
  188 + @FindBy (xpath = "//a[@name='child.text'][contains(text(),'装柜任务管理')]")
  189 + WebElement loadContainerTask;
  190 +
  191 +
185 192 /*
186 193 * 方法
187 194 */
... ... @@ -426,6 +433,18 @@ public class HomePage extends BasePage{
426 433 }
427 434  
428 435 /**
  436 + * 进入装柜任务处理管理页面
  437 + * @return 返回装柜任务处理管理页面
  438 + */
  439 + public NeedDealtApplyPage toLoadContainer(){
  440 + click(StorageManage);
  441 + click(loadContainerTask);
  442 + dynamicWait(By.xpath("//div[@class='loading ng-scope']"));
  443 + forceWait(3000);
  444 + return new NeedDealtApplyPage(driver);
  445 + }
  446 +
  447 + /**
429 448 * 登记备选船期待办
430 449 * @return 进入登记船务船期待办详情页面
431 450 */
... ...
src/main/java/com/essa/pageObject/StorageManage/LoadContainerHandlePage.java 0 → 100644
... ... @@ -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 tail = i-2;
  58 + // 对计算结果转换成string,并赋值给“实装柜数量”
  59 + String quantity = String.valueOf(tail);
  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 @@
  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 @@
  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 55 SoftAssert anAssert = new SoftAssert();
56 56 anAssert.assertEquals(actualLoae,true,"通知装柜失败!");
57 57 anAssert.assertAll();
  58 + homePage.logout();
58 59 }
59 60  
60 61 }
... ...