Commit 06fc8adadb9805ab52ec2a61d56fc0a1c8dcef08
1 parent
9cbca2e2
123
Showing
5 changed files
with
362 additions
and
1 deletions
Show diff stats
@@ -0,0 +1,59 @@ | @@ -0,0 +1,59 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
3 | + <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> | ||
4 | + <output url="file://$MODULE_DIR$/target/classes" /> | ||
5 | + <output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
6 | + <content url="file://$MODULE_DIR$"> | ||
7 | + <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
8 | + <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
9 | + <excludeFolder url="file://$MODULE_DIR$/target" /> | ||
10 | + </content> | ||
11 | + <orderEntry type="inheritedJdk" /> | ||
12 | + <orderEntry type="sourceFolder" forTests="false" /> | ||
13 | + <orderEntry type="library" name="Maven: org.testng:testng:6.14.3" level="project" /> | ||
14 | + <orderEntry type="library" name="Maven: com.beust:jcommander:1.72" level="project" /> | ||
15 | + <orderEntry type="library" name="Maven: org.apache-extras.beanshell:bsh:2.0b6" level="project" /> | ||
16 | + <orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-java:3.11.0" level="project" /> | ||
17 | + <orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-api:3.11.0" level="project" /> | ||
18 | + <orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-edge-driver:3.11.0" level="project" /> | ||
19 | + <orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-opera-driver:3.11.0" level="project" /> | ||
20 | + <orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-remote-driver:3.11.0" level="project" /> | ||
21 | + <orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.7.9" level="project" /> | ||
22 | + <orderEntry type="library" name="Maven: org.apache.commons:commons-exec:1.3" level="project" /> | ||
23 | + <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" /> | ||
24 | + <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" /> | ||
25 | + <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.2" level="project" /> | ||
26 | + <orderEntry type="library" name="Maven: com.google.guava:guava:23.6-jre" level="project" /> | ||
27 | + <orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" /> | ||
28 | + <orderEntry type="library" name="Maven: org.checkerframework:checker-compat-qual:2.0.0" level="project" /> | ||
29 | + <orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.1.3" level="project" /> | ||
30 | + <orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" /> | ||
31 | + <orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" /> | ||
32 | + <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.3" level="project" /> | ||
33 | + <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.6" level="project" /> | ||
34 | + <orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.9.1" level="project" /> | ||
35 | + <orderEntry type="library" name="Maven: com.squareup.okio:okio:1.13.0" level="project" /> | ||
36 | + <orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-firefox-driver:3.11.0" level="project" /> | ||
37 | + <orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-chrome-driver:3.11.0" level="project" /> | ||
38 | + <orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-safari-driver:3.11.0" level="project" /> | ||
39 | + <orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-ie-driver:3.11.0" level="project" /> | ||
40 | + <orderEntry type="library" name="Maven: org.seleniumhq.selenium:selenium-support:2.46.0" level="project" /> | ||
41 | + <orderEntry type="library" name="Maven: javax.mail:mail:1.4" level="project" /> | ||
42 | + <orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" /> | ||
43 | + <orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" /> | ||
44 | + <orderEntry type="library" name="Maven: org.apache.poi:poi:3.14" level="project" /> | ||
45 | + <orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:3.14" level="project" /> | ||
46 | + <orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.03" level="project" /> | ||
47 | + <orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:3.14" level="project" /> | ||
48 | + <orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:2.6.0" level="project" /> | ||
49 | + <orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" /> | ||
50 | + <orderEntry type="library" name="Maven: commons-io:commons-io:1.3.2" level="project" /> | ||
51 | + <orderEntry type="library" name="Maven: mysql:mysql-connector-java:6.0.6" level="project" /> | ||
52 | + <orderEntry type="library" name="Maven: org.dbunit:dbunit:2.5.4" level="project" /> | ||
53 | + <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.21" level="project" /> | ||
54 | + <orderEntry type="library" name="Maven: junit:junit:4.12" level="project" /> | ||
55 | + <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> | ||
56 | + <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" /> | ||
57 | + <orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" /> | ||
58 | + </component> | ||
59 | +</module> | ||
0 | \ No newline at end of file | 60 | \ No newline at end of file |
@@ -0,0 +1,60 @@ | @@ -0,0 +1,60 @@ | ||
1 | +package com.essa.framework; | ||
2 | +import java.sql.*; | ||
3 | + | ||
4 | +public class LinkSQL { | ||
5 | + | ||
6 | + public static void main(String[] args) { | ||
7 | + LinkSQL dao = new LinkSQL(); | ||
8 | + dao.SQLQuery(); | ||
9 | + | ||
10 | + } | ||
11 | + | ||
12 | + public static String SQLQuery() { | ||
13 | + | ||
14 | + String Code = null; | ||
15 | + Connection conn = null; | ||
16 | + Statement stmt = null; | ||
17 | + ResultSet rs = null; | ||
18 | + | ||
19 | + try { | ||
20 | + Class.forName("com.mysql.jdbc.Driver"); | ||
21 | +// 连接SIT环境的数据库 | ||
22 | + conn = DriverManager.getConnection("jdbc:mysql://192.168.1.247:3307/bpms","root","redhat"); | ||
23 | + | ||
24 | + stmt = conn.createStatement(); | ||
25 | + | ||
26 | +// 查询FO单在制单中的PO单号 | ||
27 | + rs =stmt.executeQuery("SELECT p.code FROM fact_fo as f INNER JOIN sale_po as p ON f.from_id=p.id WHERE send_order_status=2 AND from_type=1 ORDER BY f.id DESC LIMIT 1"); | ||
28 | + | ||
29 | + while (rs.next()) { | ||
30 | + Code = rs.getString("code"); | ||
31 | + } | ||
32 | + return Code; | ||
33 | + | ||
34 | + } catch (ClassNotFoundException e) { | ||
35 | + System.out.println("驱动类无法找到!"); | ||
36 | + throw new RuntimeException(e); | ||
37 | + | ||
38 | + } catch (SQLException e) { | ||
39 | + System.out.println("数据库访问异常!"); | ||
40 | + throw new RuntimeException(e); | ||
41 | + }finally { | ||
42 | + //关闭链接资源 | ||
43 | + try { | ||
44 | + if (rs !=null) { | ||
45 | + rs.close(); | ||
46 | + } | ||
47 | + if (stmt !=null) { | ||
48 | + stmt.cancel(); | ||
49 | + } | ||
50 | + if (conn !=null) { | ||
51 | + conn.close(); | ||
52 | + } | ||
53 | + | ||
54 | + } catch (SQLException e) { | ||
55 | + System.out.println("关闭连接时发生异常"); | ||
56 | + e.printStackTrace(); | ||
57 | + } | ||
58 | + } | ||
59 | + } | ||
60 | +} |
src/main/java/com/essa/pageObject/HomePage.java
1 | package com.essa.pageObject; | 1 | package com.essa.pageObject; |
2 | 2 | ||
3 | -import org.openqa.selenium.WebDriver; | 3 | +import com.essa.pageObject.ReceiptCore.ReceiptCorePage; |
4 | +import org.openqa.selenium.WebDriver; | ||
4 | import org.openqa.selenium.WebElement; | 5 | import org.openqa.selenium.WebElement; |
5 | import org.openqa.selenium.support.FindBy; | 6 | import org.openqa.selenium.support.FindBy; |
6 | import com.essa.framework.BasePage; | 7 | import com.essa.framework.BasePage; |
@@ -157,6 +158,10 @@ public class HomePage extends BasePage{ | @@ -157,6 +158,10 @@ public class HomePage extends BasePage{ | ||
157 | //PO跟单 | 158 | //PO跟单 |
158 | @FindBy (xpath ="//*[text()='PO跟单']") | 159 | @FindBy (xpath ="//*[text()='PO跟单']") |
159 | WebElement PODocumentary; | 160 | WebElement PODocumentary; |
161 | + | ||
162 | + //前台发单中心 | ||
163 | + @FindBy (xpath ="//*[text()='前台发单中心']") | ||
164 | + WebElement Receipt_core ; | ||
160 | 165 | ||
161 | //仓储管理 | 166 | //仓储管理 |
162 | @FindBy (xpath = "//span[contains(text(),'仓储管理')]") | 167 | @FindBy (xpath = "//span[contains(text(),'仓储管理')]") |
@@ -426,4 +431,13 @@ public class HomePage extends BasePage{ | @@ -426,4 +431,13 @@ public class HomePage extends BasePage{ | ||
426 | switchMoreWindow(); | 431 | switchMoreWindow(); |
427 | return new NeedDealtApplyPage(driver); | 432 | return new NeedDealtApplyPage(driver); |
428 | } | 433 | } |
434 | + | ||
435 | + /* | ||
436 | + * 进入前台发单中心页面 | ||
437 | + * */ | ||
438 | + public ReceiptCorePage toReceiptCore() { | ||
439 | + click(DocumentaryManage); | ||
440 | + click(Receipt_core); | ||
441 | + return new ReceiptCorePage(driver); | ||
442 | + } | ||
429 | } | 443 | } |
430 | \ No newline at end of file | 444 | \ No newline at end of file |
src/main/java/com/essa/pageObject/ReceiptCore/ReceiptCorePage.java
0 → 100644
@@ -0,0 +1,177 @@ | @@ -0,0 +1,177 @@ | ||
1 | +package com.essa.pageObject.ReceiptCore; | ||
2 | +import com.essa.framework.BasePage; | ||
3 | +import org.openqa.selenium.By; | ||
4 | +import org.openqa.selenium.WebDriver; | ||
5 | +import org.openqa.selenium.WebElement; | ||
6 | +import org.openqa.selenium.support.FindBy; | ||
7 | + | ||
8 | + | ||
9 | +/* | ||
10 | + * 前台发单中心页面 | ||
11 | + * */ | ||
12 | + | ||
13 | + | ||
14 | +public class ReceiptCorePage extends BasePage { | ||
15 | + | ||
16 | + public ReceiptCorePage(WebDriver driver) { super(driver);} | ||
17 | + | ||
18 | + /* | ||
19 | + * 页面元素定位 | ||
20 | + * */ | ||
21 | + | ||
22 | + @FindBy (xpath = "//i[@class='iconfont icon-double-arrow-right']") | ||
23 | +// @FindBy (xpath = "//*[contains(text(),'高级查询')]") | ||
24 | + WebElement advancedQuery; //高级查询 | ||
25 | + | ||
26 | + @FindBy (xpath = "/html[1]/body[1]/div[2]/div[2]/div[1]/div[1]/div[1]/div[1]/form[2]/div[5]/div[1]/input[1]") | ||
27 | +// @FindBy (xpath = "//input[@type='text' and @ng-model='query.params.poCode']") | ||
28 | + | ||
29 | + WebElement PO_numbers; //PO单号 | ||
30 | + | ||
31 | + @FindBy (xpath = "//*[text()='查询']") | ||
32 | +// @FindBy (xpath = "//*/button[@type='submit']") | ||
33 | + | ||
34 | + WebElement Query ; //查询 | ||
35 | + | ||
36 | + @FindBy (xpath = "//tbody//tr[1]") | ||
37 | +// @FindBy (xpath = "//*[@id=\"frontSendListCtrlView\"]/div/div/table/tbody/tr[1]") | ||
38 | + | ||
39 | + WebElement list_1; //列表第一条数据 | ||
40 | + | ||
41 | + @FindBy (xpath = "/html[1]/body[1]/div[2]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/table[1]/tbody[1]") | ||
42 | + | ||
43 | + WebElement list; //列表 | ||
44 | + | ||
45 | + @FindBy (xpath = "/html[1]/body[1]/div[2]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/table[1]/tbody[1]/tr[1]/td[1]") | ||
46 | + | ||
47 | + WebElement document_code; //单据编号 | ||
48 | + | ||
49 | + @FindBy (xpath = "//*[text()='开始发单']") | ||
50 | +// @FindBy (xpath = "/html[1]/body[1]/div[2]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/button[1]") | ||
51 | + | ||
52 | + WebElement start_billing; // 开始发单 | ||
53 | + | ||
54 | + @FindBy (xpath = "//button[@class='btn btn-danger ng-scope']") | ||
55 | + | ||
56 | + WebElement start_billing_1 ; //前台发单扫码平台的开始发单 | ||
57 | + | ||
58 | + @FindBy (xpath = "//div[@class='input-group ng-isolate-scope ng-pristine ng-valid']//input[@type='text']") | ||
59 | + | ||
60 | + WebElement input_document_code;//单据编号输入框 | ||
61 | + | ||
62 | + @FindBy (xpath = "//button[@type='button' and @ng-click='clickBtn()']") | ||
63 | +// @FindBy (xpath = "//*[contains(@ng-click,'clickBtn')]") | ||
64 | + | ||
65 | + WebElement search ;// 搜索按钮 | ||
66 | + | ||
67 | + @FindBy (xpath = "//a[contains(text(),'扫码确认接单')]") | ||
68 | + | ||
69 | + WebElement Confirm_billing ; // 扫码确认接单 | ||
70 | + | ||
71 | + @FindBy (xpath = "//*[text()='接单完成']") | ||
72 | + | ||
73 | + WebElement finish_billing; //接单完成 | ||
74 | + | ||
75 | + @FindBy (xpath = "//*[contains(text(),'所选的工厂订单状态必须为“制单中”或“重新发单”')]") | ||
76 | + | ||
77 | + WebElement Fail_billing; //发单失败 | ||
78 | + | ||
79 | + @FindBy (xpath = "//*[contains(text(),'所选的工厂订单状态必须为“发单中”')]") | ||
80 | + | ||
81 | + //*[coantains(text(),'所选的工厂订单状态必须为'] | ||
82 | + // *[@data-notify='message'] | ||
83 | + //*[@data-notify='message'] and text()='所选的工厂订单状态必须为“发单中”' | ||
84 | + //*[(text()=' 所选的工厂订单状态必须为“发单中”'] | ||
85 | + | ||
86 | + WebElement Fail_order; //接单失败 | ||
87 | + | ||
88 | + @FindBy (xpath = "//*[contains(text(),'操作成功')]") | ||
89 | + | ||
90 | + WebElement Succeed_billing; //发单成功 | ||
91 | + | ||
92 | + | ||
93 | + | ||
94 | + | ||
95 | + | ||
96 | + /* | ||
97 | + * 页面方法 | ||
98 | + * */ | ||
99 | + | ||
100 | + public void BillOrder(String PO_Code) { | ||
101 | + click(advancedQuery); | ||
102 | + forceWait(1000); | ||
103 | + | ||
104 | + sendKeys(PO_numbers,PO_Code); | ||
105 | + forceWait(1000); | ||
106 | + | ||
107 | + click(Query); | ||
108 | +// forceWait(3000); | ||
109 | + | ||
110 | + dynamicWait(By.xpath("/html[1]/body[1]/div[2]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/table[1]/tbody[1]")); | ||
111 | + | ||
112 | +// actionDoubleClick(document_code); // 双击元素 | ||
113 | +// forceWait(1000); | ||
114 | + String Fo = document_code.getText(); | ||
115 | + forceWait(1000); | ||
116 | + | ||
117 | + click(start_billing); | ||
118 | + forceWait(1000); | ||
119 | + sendKeys(input_document_code,Fo); | ||
120 | + forceWait(1000); | ||
121 | + | ||
122 | + click(search); | ||
123 | + forceWait(1000); | ||
124 | + | ||
125 | + click(start_billing_1); | ||
126 | + forceWait(1000); | ||
127 | +// isVisibility(By.xpath("//*[contains(text(),'所选的工厂订单状态必须为“发单中”')]")); | ||
128 | + | ||
129 | + click(start_billing); | ||
130 | + forceWait(1000); | ||
131 | + | ||
132 | + click(Confirm_billing); | ||
133 | + forceWait(1000); | ||
134 | + | ||
135 | + sendKeys(input_document_code,Fo); | ||
136 | + forceWait(1000); | ||
137 | + | ||
138 | + click(search); | ||
139 | + forceWait(1000); | ||
140 | + | ||
141 | + click(finish_billing); | ||
142 | + forceWait(3000); | ||
143 | + | ||
144 | + | ||
145 | + | ||
146 | + } | ||
147 | + | ||
148 | + | ||
149 | + /* | ||
150 | + *用于断言发单接单是否成功 | ||
151 | + * @return boolean | ||
152 | + */ | ||
153 | + | ||
154 | + public boolean isSucceed() {return isElementExist(Succeed_billing);} | ||
155 | + | ||
156 | + /* | ||
157 | + *用于断言发单是否成功 | ||
158 | + * @return boolean | ||
159 | + */ | ||
160 | + | ||
161 | + public boolean FailBilling() {return isElementExist(Fail_billing);} | ||
162 | + | ||
163 | + /* | ||
164 | + *用于断言接单是否成功 | ||
165 | + * @return boolean | ||
166 | + */ | ||
167 | + | ||
168 | + | ||
169 | + public boolean FailOrder() {return isElementExist(Fail_order);} | ||
170 | + | ||
171 | + | ||
172 | + | ||
173 | + | ||
174 | + | ||
175 | + | ||
176 | + | ||
177 | +} |
src/main/java/com/essa/testSuite/TestReceiptCore.java
0 → 100644
@@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
1 | +package com.essa.testSuite; | ||
2 | +import com.essa.framework.LinkSQL; | ||
3 | +import com.essa.pageObject.BaseTest; | ||
4 | +import com.essa.pageObject.HomePage; | ||
5 | +import com.essa.pageObject.ReceiptCore.ReceiptCorePage; | ||
6 | +import org.openqa.selenium.WebDriver; | ||
7 | +import org.openqa.selenium.support.PageFactory; | ||
8 | +import org.testng.annotations.AfterClass; | ||
9 | +import org.testng.annotations.BeforeClass; | ||
10 | +import org.testng.annotations.Test; | ||
11 | +import org.testng.asserts.SoftAssert; | ||
12 | + | ||
13 | + | ||
14 | +public class TestReceiptCore extends BaseTest { | ||
15 | + WebDriver driver ; | ||
16 | + | ||
17 | + @BeforeClass | ||
18 | + public void setUp() { | ||
19 | + initsetUp(); | ||
20 | + loginValid("zhidanbu"); | ||
21 | + } | ||
22 | + | ||
23 | + @AfterClass | ||
24 | + public void tearDown() {driver.quit();} | ||
25 | + | ||
26 | + /* | ||
27 | + * PO发单接单 | ||
28 | + * */ | ||
29 | + @Test( ) | ||
30 | + public void receiptcore () { | ||
31 | + this.driver = getDriver(); | ||
32 | + HomePage homePage = PageFactory.initElements(driver,HomePage.class); | ||
33 | + homePage.toReceiptCore(); | ||
34 | + ReceiptCorePage receiptCorePage = PageFactory.initElements(driver,ReceiptCorePage.class); | ||
35 | + String PO = LinkSQL.SQLQuery(); | ||
36 | + | ||
37 | + receiptCorePage.BillOrder(PO); | ||
38 | + | ||
39 | + SoftAssert softAssert = new SoftAssert(); | ||
40 | + boolean SucceedElement = receiptCorePage.isSucceed(); | ||
41 | +// boolean FailElement = receiptCorePage.FailBilling(); | ||
42 | +// boolean FailElement1 = receiptCorePage.FailOrder(); | ||
43 | + System.out.println(SucceedElement); | ||
44 | + | ||
45 | + softAssert.assertEquals(SucceedElement,true,"发单接单失败"); | ||
46 | + softAssert.assertAll(); | ||
47 | + | ||
48 | + | ||
49 | + } | ||
50 | + | ||
51 | +} |