Commit 3f06ee1ccf88b2c501eb8c94ee4a7a81ff02d821

Authored by zengjin
1 parent aaa54ba4

修改时间工具,还有船务相关

Showing 22 changed files with 301 additions and 90 deletions   Show diff stats
src/main/java/com/buyer/pageObject/PayDepositPage.java
... ... @@ -52,11 +52,9 @@ public class PayDepositPage extends BasePage {
52 52 }
53 53  
54 54 public void operate() {
55   - /*while (!(isVisibility(By.xpath("//*[contains(text(),'PO information')]")))) {
56   - forceWait(1000);
57   - }*/
58 55 dynamicWait(By.xpath("//*[contains(text(),'PO information')]"));
59 56 Model.setPoNum(poNum.getText());
  57 +
60 58 if (isVisibility(By.xpath("//button[@class='submit-payment-deposit-button btn btn-primary']"))) {
61 59 //如果是可用资金不足,跳转到资金管理
62 60 toAssetManagementPage();
... ...
src/main/java/com/essa/framework/BasePage.java
... ... @@ -520,6 +520,16 @@ public class BasePage {
520 520 // Logger.Output(LogType.LogTypeName.INFO, "等待元素在页面上加载可见,最多5秒");
521 521 wait.until(ExpectedConditions.visibilityOf(element));
522 522 }
  523 +
  524 + /**要的元素是否存在,传递元素表达式,最多5秒
  525 + * @param
  526 + */
  527 + protected void mywait(By by) {
  528 +
  529 + WebDriverWait wait = new WebDriverWait(driver, 7);
  530 +// Logger.Output(LogType.LogTypeName.INFO, "等待元素在页面上加载可见,最多5秒");
  531 + wait.until(ExpectedConditions.visibilityOf(driver.findElement(by)));
  532 + }
523 533  
524 534 /**
525 535 * 设立检查点,判断页面是否是我们要的
... ... @@ -665,8 +675,8 @@ public class BasePage {
665 675 * @param by
666 676 */
667 677 protected void dynamicWait(By by) {
668   - for(int count=0;count<7&&!(isVisibility(by));count++) {
669   - forceWait(1000);
  678 + for(int count=0;count<14&&!(isVisibility(by));count++) {
  679 + forceWait(500);
670 680 }
671 681 }
672 682 // /**
... ... @@ -681,8 +691,8 @@ public class BasePage {
681 691 * @param by
682 692 */
683 693 protected void dynamicLoad(By by) {
684   - for(int count=0;count<7&&isVisibility(by);count++) {
685   - forceWait(1000);
  694 + for(int count=0;count<14&&isVisibility(by);count++) {
  695 + forceWait(500);
686 696 }
687 697 }
688 698 /**
... ...
src/main/java/com/essa/framework/Model.java
... ... @@ -9,20 +9,29 @@ public class Model {
9 9 public static String skuNo;//商品编号
10 10 public static String buyerNo;//采购商编号
11 11 public static String supplierName;//供应商名称
12   - public static String picPath = "C:\\Users\\Administrator\\Pictures\\Camera Roll\\ya.jpg";//图片路径
  12 + public static String picPath;//图片路径
13 13 public static String email = "buyer"+Tools.getTime()+"@essa.cn";//采购商邮箱
14 14 public static String invateCode;//邀请码
15 15 public static String env;//所选环境
16   - public static String buyerAccount="meng18@essa.cn";//采购商账号
17   - public static String buyerPassword="essa123";//采购商密码
18   - public static String poNum="A181115T9194K";//po单号
  16 + public static String buyerAccount;//采购商账号
  17 + public static String buyerPassword;//采购商密码
  18 + public static String poNum = "DK180126T0278";//po单号
19 19 public static int isactivity=0;//是否是活动商品 1:是 0:否
20 20 public static String manager;//商品的类目经理
21   - public static String serialNum="RW2018060800058";//待办流水号
  21 + public static String serialNum;//待办流水号
22 22 public static String materialName;//物料名称
23 23 public static String projectName;//项目立项书名称
  24 + public static String salesman="yanqingping";//业务员
24 25  
25   - public static String getProjectName() {
  26 + public static String getSalesman() {
  27 + return salesman;
  28 + }
  29 +
  30 + public static void setSalesman(String salesman) {
  31 + Model.salesman = salesman;
  32 + }
  33 +
  34 + public static String getProjectName() {
26 35 return projectName;
27 36 }
28 37  
... ...
src/main/java/com/essa/framework/SuitesEnum.java
... ... @@ -19,7 +19,8 @@ public enum SuitesEnum {
19 19 ACTIVITY_SEND_PO("ACTIVITY_SEND_PO","activitySendPO.xml","生成PO(活动)"),
20 20 SEND_PO("SEND_PO","sendPO.xml","生成PO(正常)"),
21 21 PO_INQUIRY("PO_INQUIRY","POInquiry.xml","PO询价"),
22   - ADD_DEV_GOODS("ADD_DEV_GOODS","addDevGoods.xml","新增开发商品");
  22 + ADD_DEV_GOODS("ADD_DEV_GOODS","addDevGoods.xml","新增开发商品"),
  23 + LOAD_FINISH("LOAD_FINISH","LoadContainer.xml","装柜完成");
23 24 ;
24 25  
25 26 /**
... ...
src/main/java/com/essa/framework/Tools.java
1 1 package com.essa.framework;
2 2  
3 3 import java.text.SimpleDateFormat;
  4 +import java.time.Year;
  5 +import java.util.Calendar;
4 6 import java.util.Date;
5 7  
6 8 public class Tools {
... ... @@ -37,5 +39,52 @@ public class Tools {
37 39 int i = (int)(1+Math.random()*(10-1+1));
38 40 return time+i;
39 41 }
40   -
  42 + /**
  43 + *获取当前时间的下一个月
  44 + * @param
  45 + * @return String 格式化后的时间
  46 + */
  47 + public static String getNextMonth(){
  48 + Date today = new Date();
  49 + Calendar cal = Calendar.getInstance();
  50 + cal.setTime(today);
  51 + cal.add(Calendar.MONTH,1);
  52 + return myForm(cal);
  53 + }
  54 + /**
  55 + *获取当前时间+i天,传入的i为当前时间往后推的天数
  56 + * @param
  57 + * @return String
  58 + */
  59 + public static String moreDays(int i){
  60 + Date today = new Date();
  61 + Calendar cal = Calendar.getInstance();
  62 + cal.setTime(today);
  63 + cal.add(Calendar.DATE,i);
  64 + return myForm(cal);
  65 + }
  66 +
  67 + /**
  68 + *获取格式化后的当天
  69 + * @param
  70 + * @return String
  71 + */
  72 + public static String getToday(){
  73 + Date today = new Date();
  74 + Calendar cal = Calendar.getInstance();
  75 + cal.setTime(today);
  76 + return myForm(cal);
  77 + }
  78 +
  79 + /**
  80 + *由于bpms系统遇到日期中“天”为0开头时无法输入,故自己写一个格式
  81 + * @param
  82 + * @return
  83 + */
  84 + public static String myForm(Calendar cal){
  85 + int day = cal.get(Calendar.DATE);
  86 + int month = cal.get(Calendar.MONTH)+1;
  87 + int year = cal.get(Calendar.YEAR);
  88 + return month+"/"+day+"/"+ year;
  89 + }
41 90 }
... ...
src/main/java/com/essa/pageObject/DocumentaryManage/POBoardPage.java
1 1 package com.essa.pageObject.DocumentaryManage;
2 2  
3 3 import com.essa.framework.Model;
  4 +import com.essa.framework.Tools;
4 5 import org.openqa.selenium.By;
5 6 import org.openqa.selenium.WebDriver;
6 7  
... ... @@ -9,7 +10,11 @@ import org.openqa.selenium.WebElement;
9 10 import org.openqa.selenium.support.FindBy;
10 11  
11 12 import java.util.Date;
12   -
  13 +/**
  14 +* @Description: Po看板页面
  15 +* @Author: ZengJin
  16 +* @CreateTime: 2018/11/1
  17 +*/
13 18 public class POBoardPage extends BasePage {
14 19  
15 20 public POBoardPage(WebDriver driver) {
... ... @@ -88,8 +93,7 @@ public class POBoardPage extends BasePage {
88 93 public POBoardPage noticeReceive(){
89 94 click(noticeReceive);
90 95 jsExecutorRemoveAttribute(inputReceiveDate,"readonly");
91   - String date = getDateTimeByFormat(new Date(),"MM/dd/yyyy");
92   - sendKeys(inputReceiveDate,date);
  96 + sendKeys(inputReceiveDate, Tools.getToday());
93 97 click(reveiveDate);
94 98 click(submit);
95 99 return new POBoardPage(driver);
... ... @@ -104,8 +108,7 @@ public class POBoardPage extends BasePage {
104 108 public POBoardPage noticeLoad(){
105 109 click(noticeLoad);
106 110 jsExecutorRemoveAttribute(inutLoadDate,"readonly");
107   - String date = getDateTimeByFormat(new Date(),"MM/dd/yyyy");
108   - sendKeys(inutLoadDate,date);
  111 + sendKeys(inutLoadDate,Tools.getToday());
109 112 click(loadDate);
110 113 forceWait(1000);
111 114 click(submit);
... ...
src/main/java/com/essa/pageObject/HomePage.java
... ... @@ -200,7 +200,7 @@ public class HomePage extends BasePage{
200 200 WebElement LogisticsskippBoard;
201 201  
202 202 //船务看板
203   - @FindBy (xpath = "//*[@id='essa-left-menu']/div/dl[1]/dd[2]")
  203 + @FindBy (xpath = "//*[text()='船务看板']")
204 204 WebElement skippBoard;
205 205  
206 206  
... ... @@ -444,6 +444,7 @@ public class HomePage extends BasePage{
444 444 */
445 445 public NeedDealtApplyPage toSailingDateConfirmPage() {
446 446 click(confirmDailingDate);
  447 + forceWait(1000);
447 448 click(firstNeedDealt);
448 449 switchMoreWindow();
449 450 return new NeedDealtApplyPage(driver);
... ... @@ -541,11 +542,22 @@ public class HomePage extends BasePage{
541 542 *进入船务看板界面
542 543 */
543 544 public LogisticsShippPage toLogisticsShippPage(){
544   - mywait(LogisticsskippBoard);
  545 +// mywait(LogisticsskippBoard);
545 546 click(LogisticsskippBoard);
546   - mywait(skippBoard);
  547 +// forceWait(1000);
547 548 click(skippBoard);
  549 +// jsExecutorClick(skippBoard);
548 550 return new LogisticsShippPage(driver);
549 551 }
  552 + /**
  553 + *业务员进入待办详情页,填写船务资料
  554 + * @param
  555 + * @return
  556 + */
  557 + public NeedDealtApplyPage toWriteShipping() {
  558 + click(firstNeedDealt);
  559 + switchMoreWindow();
  560 + return new NeedDealtApplyPage(driver);
  561 + }
550 562  
551 563 }
552 564 \ No newline at end of file
... ...
src/main/java/com/essa/pageObject/LogisticShipp/BookingCarPage.java
1 1 package com.essa.pageObject.LogisticShipp;
2 2  
3 3 import com.essa.framework.BasePage;
  4 +import com.essa.framework.Model;
  5 +import com.essa.framework.Tools;
4 6 import org.openqa.selenium.WebDriver;
5 7 import org.openqa.selenium.WebElement;
6 8 import org.openqa.selenium.support.FindBy;
... ... @@ -13,7 +15,7 @@ public class BookingCarPage extends BasePage {
13 15 }
14 16  
15 17 //订车看板
16   - @FindBy(xpath = "//*[@id='tableViewList']/div/div/div/ul/li[4]")
  18 + @FindBy(xpath = "//*[text()='订车']")
17 19 WebElement BookingCarBoard;
18 20  
19 21 //查询条件
... ... @@ -47,16 +49,16 @@ public class BookingCarPage extends BasePage {
47 49 public BookingCarPage toBookingCarPage() {
48 50 mywait(BookingCarBoard);
49 51 click(BookingCarBoard);
50   - SetQuery.sendKeys("D180411T0278");
  52 + SetQuery.sendKeys(Model.getPoNum());
51 53 click(QueryBtn);
52 54 forceWait(1000);
53 55 click(QueryRsult);
54 56 click(BookingCarBtn);
55 57 mywait(BookingCarSeclType);
56 58 click(BookingCarSeclType);
57   - mywait(BookingCarDate);
  59 +// mywait(BookingCarDate);
58 60 jsExecutorRemoveAttribute(BookingCarDate, "readonly");
59   - sendKeys(BookingCarDate, "2018/10/23");
  61 + sendKeys(BookingCarDate, Tools.getToday());
60 62 click(SubmitBtn);
61 63 return new BookingCarPage(driver);
62 64 }
... ...
src/main/java/com/essa/pageObject/LogisticShipp/CabinInfoPage.java
1 1 package com.essa.pageObject.LogisticShipp;
2 2  
3 3 import com.essa.framework.BasePage;
  4 +import com.essa.framework.Model;
  5 +import com.essa.framework.Tools;
  6 +import org.openqa.selenium.By;
4 7 import org.openqa.selenium.WebDriver;
5 8 import org.openqa.selenium.WebElement;
6 9 import org.openqa.selenium.support.FindBy;
... ... @@ -11,7 +14,7 @@ public class CabinInfoPage extends BasePage {
11 14 super(driver);
12 15 }
13 16  
14   - public String FilePath = "C:\Users\hanlei\Desktop\1.png";
  17 +// public String FilePath = "C:\Users\hanlei\Desktop\1.png";
15 18  
16 19 //订舱看板
17 20 @FindBy(xpath = "//*[@id='tableViewList']/div/div/div/ul/li[3]")
... ... @@ -57,25 +60,36 @@ public class CabinInfoPage extends BasePage {
57 60 @FindBy(xpath = "/html/body/div[6]/div/div/div[2]/div")
58 61 WebElement Body;
59 62  
  63 + //预计到港时间
  64 + @FindBy (xpath = "//*[@id='expectArrivalTime']")
  65 + WebElement expectArrivalTime;
  66 +
  67 +
60 68 public CabinInfoPage toCabinInfoPage() {
  69 + forceWait(1000);
61 70 click(BookingCabin);
62 71 mywait(FirstDate);
63   - SetQuery.sendKeys("D180411T0278");
  72 + SetQuery.sendKeys(Model.getPoNum());
64 73 click(QueryBtn);
65   - mywait(SelectFirstDate);
  74 +// mywait(SelectFirstDate);
  75 + forceWait(1000);
66 76 click(SelectFirstDate);
67 77 click(BookingCabinBtn);
68 78 mywait(SetCabinSONo);
69 79 SetCabinSONo.sendKeys("TestCabinNo");
  80 + jsExecutorRemoveAttribute(expectArrivalTime,"readonly");
  81 + sendKeys(expectArrivalTime,Tools.getNextMonth());
70 82 jsExecutorRemoveAttribute(LastLoadTimeSet, "readonly");
71   - sendKeys(LastLoadTimeSet,"10/23/2018");
  83 + sendKeys(LastLoadTimeSet, Tools.getToday());//最后装柜时间设置为今天
72 84 // LastLoadTimeSet.sendKeys("10/23/2018");
73 85 click(Body);
74 86 // jsExecutorClick(FileUp);
75 87 actionClick(FileUp);
76   - uploadFile(FilePath);
77   - forceWait(2000);
  88 + uploadFile(Model.getPicPath());
  89 +// forceWait(2000);
  90 + dynamicLoad(By.xpath("//img[@ng-src='/img/nopic.jpg']"));//直到默认的图片找不到时,执行下一步
78 91 click(CommitBtn);
  92 + dynamicLoad();
79 93 return new CabinInfoPage(driver);
80 94 }
81 95 }
... ...
src/main/java/com/essa/pageObject/LogisticShipp/LogisticsShippPage.java
... ... @@ -2,6 +2,9 @@ package com.essa.pageObject.LogisticShipp;
2 2  
3 3  
4 4 import com.essa.framework.BasePage;
  5 +import com.essa.framework.Model;
  6 +import com.essa.pageObject.HomePage;
  7 +import org.openqa.selenium.By;
5 8 import org.openqa.selenium.WebDriver;
6 9 import org.openqa.selenium.WebElement;
7 10 import org.openqa.selenium.support.FindBy;
... ... @@ -45,10 +48,12 @@ public class LogisticsShippPage extends BasePage {
45 48 WebElement logout;
46 49  
47 50 //搜索并通知业务补充船务资料
48   - public LogisticsShippPage isSucceed() {
  51 + public HomePage isSucceed() {
  52 + forceWait(1000);
49 53 click(NoticeBoard);
50   - mywait(resultDate);
51   - setPono.sendKeys("D180411T0278");
  54 + dynamicWait(By.xpath("//tbody/tr[1]/td[1]/input[1]"));//列表加载
  55 +// setPono.sendKeys("D180411T0278");
  56 + sendKeys(setPono, Model.getPoNum());
52 57 click(querySubBtn);
53 58 mywait(selectedpo);
54 59 click(selectedpo);
... ... @@ -56,6 +61,10 @@ public class LogisticsShippPage extends BasePage {
56 61 click(skippSubBtn);
57 62 mywait(submitSubBtn);
58 63 click(submitSubBtn);
59   - return new LogisticsShippPage(driver);
  64 + String saleman = DBSqlSearch("select a.account_name from pri_user a INNER JOIN\n" +
  65 + "sale_po b on a.id=b.salesman_id\n" +
  66 + "where b.`code` = '"+ Model.getPoNum()+"';","account_name");//根据PO单号查出对应的业务员
  67 + Model.setSalesman(saleman);//将查询出的业务员存储在model中
  68 + return new HomePage(driver);
60 69 }
61 70 }
... ...
src/main/java/com/essa/pageObject/LogisticShipp/SendCarPage.java
1 1 package com.essa.pageObject.LogisticShipp;
2 2  
3 3 import com.essa.framework.BasePage;
  4 +import com.essa.framework.Model;
4 5 import org.openqa.selenium.WebDriver;
5 6 import org.openqa.selenium.WebElement;
6 7 import org.openqa.selenium.support.FindBy;
... ... @@ -48,10 +49,12 @@ public class SendCarPage extends BasePage {
48 49 WebElement SubmitBtn;
49 50  
50 51 public SendCarPage toSendCarPage() {
  52 + forceWait(1000);
51 53 click(BookingCarBoard);
52 54 mywait(WaitForBookingCarBoard);
53 55 click(WaitForBookingCarBoard);
54   - QueryWaitForBooking.sendKeys("D180411T0278");
  56 + forceWait(500);
  57 + QueryWaitForBooking.sendKeys(Model.getPoNum());
55 58 click(QueryWaitForBookingCarBtn);
56 59 mywait(FristWaitForBookingCarDate);
57 60 click(FristWaitForBookingCarDate);
... ...
src/main/java/com/essa/pageObject/PODocumentary/POBoardPage.java
1 1 package com.essa.pageObject.PODocumentary;
2 2  
  3 +import com.essa.framework.Tools;
3 4 import org.openqa.selenium.By;
4 5 import org.openqa.selenium.WebDriver;
5 6 import com.essa.framework.BasePage;
... ... @@ -64,8 +65,8 @@ public class POBoardPage extends BasePage {
64 65 public POBoardPage toNotificationLoading(){
65 66 click(NotificationLoading);
66 67 jsExecutorRemoveAttribute(loadingDate,"readonly");
67   - String Loadingdate = getDateTimeByFormat(new Date(), "MM/dd/yyyy");
68   - sendKeys(loadingDate,Loadingdate);
  68 +// String Loadingdate = getDateTimeByFormat(new Date(), "MM/dd/yyyy");
  69 + sendKeys(loadingDate, Tools.getToday());
69 70 click(BlankPlace);
70 71 click(submit);
71 72 forceWait(4000);
... ...
src/main/java/com/essa/pageObject/StorageManage/LoadContainerHandlePage.java
... ... @@ -2,6 +2,7 @@ package com.essa.pageObject.StorageManage;
2 2  
3 3 import com.essa.framework.BasePage;
4 4 import com.essa.framework.Model;
  5 +import com.essa.framework.Tools;
5 6 import org.openqa.selenium.By;
6 7 import org.openqa.selenium.WebDriver;
7 8 import org.openqa.selenium.WebElement;
... ... @@ -48,8 +49,8 @@ public class LoadContainerHandlePage extends BasePage {
48 49 public LoadContainerHandlePage loadTaskHandle(){
49 50 forceWait(1000);
50 51 jsExecutorRemoveAttribute(actLoadTime,"readonly");
51   - String date = getDateTimeByFormat(new Date(), "MM/dd/yyyy");
52   - sendKeys(actLoadTime,date);
  52 +// String date = getDateTimeByFormat(new Date(), "MM/dd/yyyy");
  53 + sendKeys(actLoadTime, Tools.getToday());
53 54 // 获取‘可装柜数量’字符串中的数量
54 55 String qua = partiaStr(mayLoadQuantity,0,1);
55 56 // 对切片结果进行int转换
... ...
src/main/java/com/essa/pageObject/StorageManage/LoadContainerManagePage.java
... ... @@ -7,7 +7,11 @@ import org.openqa.selenium.By;
7 7 import org.openqa.selenium.WebDriver;
8 8 import org.openqa.selenium.WebElement;
9 9 import org.openqa.selenium.support.FindBy;
10   -
  10 +/**
  11 +* @Description: 装柜任务管理列表
  12 +* @Author: ZengJin
  13 +* @CreateTime: 2018/11/1
  14 +*/
11 15 public class LoadContainerManagePage extends BasePage {
12 16  
13 17 public LoadContainerManagePage(WebDriver driver) {
... ...
src/main/java/com/essa/pageObject/LogisticShipp/LargeDcofdPage.java renamed to src/main/java/com/essa/pageObject/needDealt/LargeDcofdPage.java
1   -package com.essa.pageObject.LogisticShipp;
  1 +package com.essa.pageObject.needDealt;
2 2  
3 3 import com.essa.framework.BasePage;
  4 +import com.essa.pageObject.HomePage;
  5 +import org.openqa.selenium.By;
4 6 import org.openqa.selenium.WebDriver;
5 7 import org.openqa.selenium.WebElement;
6 8 import org.openqa.selenium.support.FindBy;
... ... @@ -15,9 +17,16 @@ public class LargeDcofdPage extends BasePage {
15 17 @FindBy(xpath = "//*[@id='tableViewList']/div/div/div/div[4]/span[1]/button[2]")
16 18 WebElement ConfirmationShipDate;
17 19  
18   - public LargeDcofdPage toLargeDcofdPage(){
19   - mywait(ConfirmationShipDate);
  20 + /**
  21 + *大跟单确认船期
  22 + * @param
  23 + * @return
  24 + */
  25 + public HomePage toLargeDcofdPage(){
  26 +// mywait(ConfirmationShipDate);
  27 + dynamicWait(By.xpath("//*[contains(text(),'待办工作')]"));
20 28 click(ConfirmationShipDate);
21   - return new LargeDcofdPage(driver);
  29 + dynamicLoad();
  30 + return new HomePage(driver);
22 31 }
23 32 }
... ...
src/main/java/com/essa/pageObject/needDealt/NeedDealtApplyPage.java
1 1 package com.essa.pageObject.needDealt;
2 2  
  3 +import com.essa.framework.Tools;
3 4 import org.openqa.selenium.By;
4 5 import org.openqa.selenium.JavascriptExecutor;
5 6 import org.openqa.selenium.WebDriver;
... ... @@ -10,6 +11,8 @@ import com.essa.framework.BasePage;
10 11 import com.essa.framework.Model;
11 12 import com.essa.pageObject.HomePage;
12 13  
  14 +import java.util.Date;
  15 +
13 16 /**
14 17 * 当团购活动成功时,类目经理采购计划单申请页面
15 18 * @author Administrator
... ... @@ -157,11 +160,12 @@ public class NeedDealtApplyPage extends BasePage {
157 160 //设置开船日期
158 161 jsExecutorRemoveAttribute(inputShipperStartDate,"readonly");
159 162 inputShipperStartDate.clear();
160   - sendKeys(inputShipperStartDate,"10/25/2018");
  163 +// String date = getDateTimeByFormat(new Date(),"MM/dd/yyyy");
  164 + sendKeys(inputShipperStartDate, Tools.getNextMonth());
161 165 //设置预计到港日期
162 166 jsExecutorRemoveAttribute(inputShipperArriveDate,"readonly");
163 167 inputShipperArriveDate.clear();
164   - sendKeys(inputShipperArriveDate,"11/10/2018");
  168 + sendKeys(inputShipperArriveDate,Tools.getNextMonth());
165 169 //提交
166 170 click(submit);
167 171 dynamicLoad();
... ...
src/main/java/com/essa/pageObject/LogisticShipp/RegisOptShpDatePage.java renamed to src/main/java/com/essa/pageObject/needDealt/RegisOptShpDatePage.java
1   -package com.essa.pageObject.LogisticShipp;
  1 +package com.essa.pageObject.needDealt;
2 2  
3 3 import com.essa.framework.BasePage;
  4 +import com.essa.framework.Model;
  5 +import com.essa.framework.Tools;
  6 +import com.essa.pageObject.HomePage;
  7 +import org.openqa.selenium.By;
4 8 import org.openqa.selenium.WebDriver;
5 9 import org.openqa.selenium.WebElement;
6 10 import org.openqa.selenium.support.FindBy;
... ... @@ -35,19 +39,32 @@ public class RegisOptShpDatePage extends BasePage {
35 39 @FindBy(xpath = "//*[@id='tableViewList']/div/div/div/div[4]/span[1]/button[2]")
36 40 WebElement SubmitBtn;
37 41  
38   - public RegisOptShpDatePage toRegisOptShpDatePage(){
39   - mywait(ClaimTask);
40   - forceWait(1000);
41   - click(ClaimTask);
  42 + //流水号
  43 + @FindBy (xpath = "//*[contains(text(),'流水号:RW')]")
  44 + WebElement serialNumber;
  45 +
  46 + /**
  47 + *登记船期
  48 + * @param
  49 + * @return HomePage
  50 + */
  51 + public HomePage toRegisOptShpDatePage(){
  52 + dynamicWait(By.xpath("//*[contains(text(),'待办工作')]"));
  53 + if (isVisibility(By.xpath("//*[@id='tableViewList']/div/div/div/div[4]/button"))){
  54 + click(ClaimTask);//如果需要认领,则认领
  55 + forceWait(4000);
  56 + }
42 57 mywait(AddShippInfo);
  58 + Model.setSerialNum(partialStr(serialNumber.getText(), "流水号:"));
43 59 click(AddShippInfo);
44 60 mywait(AddShippCompanyInfo);
45 61 AddShippCompanyInfo.sendKeys("TestShippCompanyInfo");
46 62 jsExecutorRemoveAttribute(SetdeliveryDate0, "readonly");
47   - sendKeys(SetdeliveryDate0,"10/23/2018");
  63 + sendKeys(SetdeliveryDate0, Tools.moreDays(20));
48 64 jsExecutorRemoveAttribute(SetEstimatedArrivalDate0, "readonly");
49   - sendKeys(SetEstimatedArrivalDate0,"10/23/2018");
  65 + sendKeys(SetEstimatedArrivalDate0,Tools.moreDays(20));
50 66 click(SubmitBtn);
51   - return new RegisOptShpDatePage(driver);
  67 + dynamicLoad();
  68 + return new HomePage(driver);
52 69 }
53 70 }
... ...
src/main/java/com/essa/pageObject/LogisticShipp/SellerFillInfoPage.java renamed to src/main/java/com/essa/pageObject/needDealt/SellerFillInfoPage.java
1   -package com.essa.pageObject.LogisticShipp;
  1 +package com.essa.pageObject.needDealt;
2 2  
3 3 import com.essa.framework.BasePage;
  4 +import com.essa.framework.Model;
  5 +import com.essa.pageObject.HomePage;
  6 +import org.openqa.selenium.By;
4 7 import org.openqa.selenium.WebDriver;
5 8 import org.openqa.selenium.WebElement;
6 9 import org.openqa.selenium.support.FindBy;
... ... @@ -95,12 +98,23 @@ public class SellerFillInfoPage extends BasePage {
95 98 @FindBy(xpath = "//*[text()='确认']")
96 99 WebElement SubmitBtn;
97 100  
98   - public SellerFillInfoPage toSellerFillInfo() {
99   - mywait(AppointSet);
  101 + //流水号
  102 + @FindBy (xpath = "//*[contains(text(),'流水号:RW')]")
  103 + WebElement serialNumber;
  104 +
  105 + /**
  106 + *业务员填写船务资料
  107 + * @param
  108 + * @return
  109 + */
  110 + public HomePage toSellerFillInfo() {
  111 +// mywait(AppointSet);
  112 + dynamicWait(By.xpath("//*[contains(text(),'待办工作')]"));
  113 + Model.setSerialNum(partialStr(serialNumber.getText(), "流水号:"));//将流水号传递出去
100 114 click(AppointSet);
101 115 click(DeclareSet);
102 116 click(AppointCompanySet);
103   - mywait(AppointCompanySec);
  117 + forceWait(1000);
104 118 click(AppointCompanySec);
105 119 click(CommitAppointCompanySec);
106 120 mywait(TargetPortSet);
... ... @@ -122,6 +136,7 @@ public class SellerFillInfoPage extends BasePage {
122 136 MailZipcode.sendKeys("TestMailZipCode");
123 137 MailFax.sendKeys("TestMailFax");
124 138 click(SubmitBtn);
125   - return new SellerFillInfoPage(driver);
  139 + dynamicLoad();
  140 + return new HomePage(driver);
126 141 }
127 142 }
... ...
src/main/java/com/essa/testSuite/TestConfirLogistics.java
1 1 package com.essa.testSuite;
2 2  
  3 +import com.essa.framework.Model;
3 4 import com.essa.pageObject.LogisticShipp.*;
  5 +import com.essa.pageObject.needDealt.LargeDcofdPage;
  6 +import com.essa.pageObject.needDealt.RegisOptShpDatePage;
  7 +import com.essa.pageObject.needDealt.SellerFillInfoPage;
4 8 import org.openqa.selenium.WebDriver;
5 9 import org.openqa.selenium.support.PageFactory;
6 10 import org.testng.annotations.AfterClass;
... ... @@ -36,32 +40,35 @@ public class TestConfirLogistics extends BaseTest {
36 40  
37 41 homePage.getHome();
38 42 homePage.logout();
39   - loginValid("yanqingping");
  43 + loginValid(Model.getSalesman());//登录对应的业务员账号
40 44  
41 45 //待办
42   - homePage.toSailingDateConfirmPage();
  46 +// homePage.toSailingDateConfirmPage();
  47 + homePage.toWriteShipping();
43 48 //业务员补充船务资料
44 49 SellerFillInfoPage sellerFillInfo = PageFactory.initElements(driver, SellerFillInfoPage.class);
45 50 sellerFillInfo.toSellerFillInfo();
46 51  
47 52 //登记备选船期待办
48   - homePage.getHome();
  53 +// homePage.getHome();
49 54 homePage.logout();
50 55 loginValid("wangmiaodan");
51 56 homePage.toSailingDateConfirmPage();
  57 +// homePage.toShippingMarkWait();//根据流水号进入待办
52 58 RegisOptShpDatePage regisOptShpDatePage = PageFactory.initElements(driver,RegisOptShpDatePage.class);
53 59 regisOptShpDatePage.toRegisOptShpDatePage();
54 60  
55 61 //大跟单确认
56   - homePage.getHome();
  62 +// homePage.getHome();
57 63 homePage.logout();
58 64 loginValid("yuwanhang");
59   - homePage.toSailingDateConfirmPage();
  65 +// homePage.toSailingDateConfirmPage();
  66 + homePage.toShippingMarkWait();//根据流水号进入待办
60 67 LargeDcofdPage largeDcofdPage = PageFactory.initElements(driver,LargeDcofdPage.class);
61 68 largeDcofdPage.toLargeDcofdPage();
62 69  
63 70 //订舱
64   - homePage.getHome();
  71 +// homePage.getHome();
65 72 homePage.logout();
66 73 loginValid("chenhong");
67 74  
... ... @@ -76,6 +83,5 @@ public class TestConfirLogistics extends BaseTest {
76 83 //确认发车
77 84 SendCarPage sendCarPage = PageFactory.initElements(driver, SendCarPage.class);
78 85 sendCarPage.toSendCarPage();
79   -
80 86 }
81 87 }
... ...
src/main/java/com/essa/testSuite/TestLoadContainer.java
... ... @@ -130,6 +130,7 @@ public class TestLoadContainer extends BaseTest {
130 130 BillingCenterPage billingCenterPage = PageFactory.initElements(driver,BillingCenterPage.class);
131 131 homePage.toBillingCenterPage();
132 132 billingCenterPage.MoreBilling();
  133 + homePage.getHome();
133 134 homePage.logout();
134 135 }
135 136 }
... ...
src/main/java/swing/SwingMain.java
... ... @@ -164,6 +164,9 @@ public class SwingMain {
164 164 frmvBy.getContentPane().add(ToCart);
165 165 ToCart.setLayout(null);
166 166  
  167 +
  168 +
  169 +
167 170 //可视化操作选项
168 171 JLabel label_1 = new JLabel("可视化操作:");
169 172 label_1.setBounds(10, 119, 88, 15);
... ... @@ -279,6 +282,7 @@ public class SwingMain {
279 282 ToCart.setVisible(false);
280 283 POInquiry.setVisible(false);
281 284 register.setVisible(false);
  285 +// loadFinish.setVisible(false);
282 286 switch ((String)selectScene.getSelectedItem()){
283 287 default:
284 288 process.setText(
... ... @@ -327,11 +331,17 @@ public class SwingMain {
327 331 addOriginal.setVisible(true);
328 332 ja.append(getCurrentTime() + "已选择场景:新增开发商品\r\n");
329 333 break;
  334 + case "装柜完成":
  335 + ToCart.setVisible(true);
  336 + ja.append(getCurrentTime() + "已选择场景:装柜完成,将重启浏览器多次\r\n");
  337 + process.setText(
  338 + "<html><body>装柜流程:<br>1.添加商品到购物车<br>2.询价并拼柜生成PO<br>3.仓储管理船务管理至装柜完成<br><br><br></body></html>");
  339 + break;
330 340 }
331 341 }
332 342 });
333 343 selectScene.setModel(
334   - new DefaultComboBoxModel(new String[] { "新增原厂商品", "新增市场商品", "发布团购", "采购商注册", "成品询价", "生成PO", "PO询价","新增开发商品" }));
  344 + new DefaultComboBoxModel(new String[] { "新增原厂商品", "新增市场商品","新增开发商品","装柜完成", "发布团购", "采购商注册", "成品询价", "生成PO", "PO询价" }));
335 345 frmvBy.getContentPane().add(selectScene);
336 346  
337 347 JLabel label_3 = new JLabel("供应商名称:");
... ... @@ -370,6 +380,15 @@ public class SwingMain {
370 380 picPath.setVisible(false);
371 381 addOriginal.add(picPath);
372 382  
  383 +// //装柜完成场景=============
  384 +// final JPanel loadFinish = new JPanel();
  385 +// loadFinish.setBounds(231, 42, 230, 128);
  386 +//// loadFinish.setVisible(false);
  387 +// loadFinish.add(picPath);//添加图片按钮
  388 +// loadFinish.add(label_7);//必填项
  389 +// frmvBy.getContentPane().add(loadFinish);
  390 +// loadFinish.setLayout(null);
  391 +
373 392 JLabel label_5 = new JLabel("采购商编号:");
374 393 label_5.setFont(new Font("微软雅黑", Font.PLAIN, 14));
375 394 label_5.setBounds(8, 15, 86, 15);
... ... @@ -449,7 +468,7 @@ public class SwingMain {
449 468 ToCart.add(account);
450 469 account.setColumns(10);
451 470  
452   - password = new JTextField();
  471 + password = new JPasswordField();
453 472 password.setText("essa123");
454 473 password.setToolTipText("");
455 474 password.setFont(new Font("微软雅黑", Font.PLAIN, 14));
... ... @@ -547,33 +566,46 @@ public class SwingMain {
547 566 setData("buyerNo", buyerNo2.getText());
548 567 setData("buyerAccount", account.getText());
549 568 ja.append(getCurrentTime() + "程序正在启动中……切勿双击【开始】\r\n");
  569 +
  570 + Model.setBuyerNo(buyerNo2.getText());
  571 + Model.setPicPath(picPath.getText());
  572 + Model.setSupplierName(supplierName.getText());
550 573 BrowserEngine.setInit(Environment, Browser);
  574 + if (!(registerAccount.getText().equals("")
  575 + || registerAccount.getText().equals("若不填写将自动生成"))) {
  576 + Model.setEmail(registerAccount.getText());
  577 + }
  578 + Model.setBuyerAccount(account.getText());
  579 + Model.setBuyerPassword(password.getText());
  580 + Model.setSkuNo(SkuNo.getText());
  581 + Model.setPoNum(po.getText());
  582 +
551 583 TestNG testNG = new TestNG();
552 584 List<String> suites = new ArrayList<String>();
553 585 switch (Scene){
554 586  
555 587 case "新增市场商品":
556   - Model.setBuyerNo(buyerNo2.getText());
557   - Model.setPicPath(picPath.getText());
558   - Model.setSupplierName(supplierName.getText());
  588 +// Model.setBuyerNo(buyerNo2.getText());
  589 +// Model.setPicPath(picPath.getText());
  590 +// Model.setSupplierName(supplierName.getText());
559 591 suites.add(SuitesEnum.ADD_MARKET_GOODS.getSuiteName());
560 592 break;
561 593 case "发布团购":
562 594 AddOriginalGoodsPage.setSupplierName(supplierName.getText());
563   - Model.setPicPath(picPath.getText());
  595 +// Model.setPicPath(picPath.getText());
564 596 suites.add(SuitesEnum.PUBLISH_GROUP_PURCHASE.getSuiteName());
565 597 break;
566 598 case "采购商注册":
567   - if (!(registerAccount.getText().equals("")
568   - || registerAccount.getText().equals("若不填写将自动生成"))) {
569   - Model.setEmail(registerAccount.getText());
570   - }
  599 +// if (!(registerAccount.getText().equals("")
  600 +// || registerAccount.getText().equals("若不填写将自动生成"))) {
  601 +// Model.setEmail(registerAccount.getText());
  602 +// }
571 603 suites.add(SuitesEnum.BUYER_REGISTER.getSuiteName());
572 604 break;
573 605 case "成品询价":
574   - Model.setBuyerAccount(account.getText());
575   - Model.setBuyerPassword(password.getText());
576   - Model.setSkuNo(SkuNo.getText());
  606 +// Model.setBuyerAccount(account.getText());
  607 +// Model.setBuyerPassword(password.getText());
  608 +// Model.setSkuNo(SkuNo.getText());
577 609 if (Model.getIsactivity() == 1) {
578 610 suites.add(SuitesEnum.ACTIVITY_INQUIRY.getSuiteName());
579 611 }else {
... ... @@ -581,9 +613,9 @@ public class SwingMain {
581 613 }
582 614 break;
583 615 case "生成PO":
584   - Model.setBuyerAccount(account.getText());
585   - Model.setBuyerPassword(password.getText());
586   - Model.setSkuNo(SkuNo.getText());
  616 +// Model.setBuyerAccount(account.getText());
  617 +// Model.setBuyerPassword(password.getText());
  618 +// Model.setSkuNo(SkuNo.getText());
587 619 if (Model.getIsactivity() == 1) {
588 620 suites.add(SuitesEnum.ACTIVITY_SEND_PO.getSuiteName());
589 621 }else {
... ... @@ -591,18 +623,24 @@ public class SwingMain {
591 623 }
592 624 break;
593 625 case "PO询价":
594   - Model.setPoNum(po.getText());
  626 +// Model.setPoNum(po.getText());
595 627 suites.add(SuitesEnum.PO_INQUIRY.getSuiteName());
596 628 break;
597 629 default : //默认新增原厂商品
598 630 AddOriginalGoodsPage.setSupplierName(supplierName.getText());
599   - Model.setPicPath(picPath.getText());
  631 +// Model.setPicPath(picPath.getText());
600 632 suites.add(SuitesEnum.ADD_ORIGINAL_GOODS.getSuiteName());
601 633 break;
602 634 case "新增开发商品":
603   - Model.setPicPath(picPath.getText());
  635 +// Model.setPicPath(picPath.getText());
604 636 suites.add(SuitesEnum.ADD_DEV_GOODS.getSuiteName());
605 637 break;
  638 + case "装柜完成":
  639 +// Model.setBuyerAccount(account.getText());
  640 +// Model.setBuyerPassword(password.getText());
  641 +// Model.setPicPath(picPath.getText());
  642 + suites.add(SuitesEnum.LOAD_FINISH.getSuiteName());
  643 + break;
606 644 }
607 645 testNG.setTestSuites(suites);
608 646 testNG.run();
... ...
src/main/resources/suites/LoadContainer.xml
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
3 3 <suite name="装柜">
4   - <!--<test name="generatePO">
  4 + <test name="generatePO">
5 5 <classes>
6 6 <class name="com.buyer.testSuite.TestAddToCart">
7 7 <methods>
... ... @@ -25,7 +25,7 @@
25 25 </methods>
26 26 </class>
27 27 </classes>
28   - </test>-->
  28 + </test>
29 29 <test name="loadContainer">
30 30 <classes>
31 31 <class name="com.essa.testSuite.TestLoadContainer">
... ... @@ -37,6 +37,11 @@
37 37 <include name="dealWithDelivery"/>
38 38 </methods>
39 39 </class>
  40 + <class name="com.essa.testSuite.TestConfirLogistics">
  41 + <methods>
  42 + <include name="confirmLogisticsTest"/>
  43 + </methods>
  44 + </class>
40 45 </classes>
41 46 </test>
42 47 </suite>
... ...