Commit a619f762b4de7530264d69a9c585095f679f1eb9
1 parent
a8f68b31
开发梳理;
Showing
10 changed files
with
86 additions
and
128 deletions
Show diff stats
src/main/java/com/essa/framework/BrowserEngine.java
... | ... | @@ -7,7 +7,6 @@ import org.openqa.selenium.ie.InternetExplorerDriver; |
7 | 7 | import org.openqa.selenium.remote.CapabilityType; |
8 | 8 | import org.openqa.selenium.remote.DesiredCapabilities; |
9 | 9 | |
10 | -import java.io.IOException; | |
11 | 10 | import java.util.concurrent.TimeUnit; |
12 | 11 | |
13 | 12 | public class BrowserEngine { |
... | ... | @@ -18,7 +17,7 @@ public class BrowserEngine { |
18 | 17 | |
19 | 18 | private ConfigProperties configProperties; |
20 | 19 | |
21 | - public void initConfigData() throws IOException{ | |
20 | + public void initConfigData() { | |
22 | 21 | env1 = null == env1 ? EnvEnum.SIT : env1; |
23 | 22 | configProperties = ConfigProperties.getConfig(env1); |
24 | 23 | browserEnum = BrowserEnum.fromCode(configProperties.getBrowserName()); |
... | ... | @@ -39,7 +38,7 @@ public class BrowserEngine { |
39 | 38 | * @return |
40 | 39 | */ |
41 | 40 | private WebDriver getBrowser(BrowserEnum browser,String url,int waitTime){ |
42 | - System.setProperty(browser.getExeName(), ".\\src\\main\\resources\\" + browser.getDriver()); | |
41 | + System.setProperty(browser.getExeName(), SystemConstant.RESOURCE_PATH + browser.getDriver()); | |
43 | 42 | switch(browser) { |
44 | 43 | case Firefox:{ |
45 | 44 | driver = new FirefoxDriver(); | ... | ... |
src/main/java/com/essa/framework/SuitesEnum.java
src/main/java/com/essa/framework/SystemConstant.java
0 → 100644
... | ... | @@ -0,0 +1,11 @@ |
1 | +package com.essa.framework; | |
2 | + | |
3 | +/** | |
4 | + * Created by weicheng on 2018/10/26. | |
5 | + */ | |
6 | +public class SystemConstant { | |
7 | + | |
8 | + public static final String RESOURCE_PATH = ".\\src\\main\\resources\\"; | |
9 | + | |
10 | + public static final String SUITES_PATH = RESOURCE_PATH + "\\suites\\"; | |
11 | +} | ... | ... |
src/main/java/com/essa/pageObject/BaseTest.java
1 | 1 | package com.essa.pageObject; |
2 | 2 | |
3 | -import java.io.IOException; | |
4 | - | |
5 | -import org.openqa.selenium.WebDriver; | |
6 | -import org.openqa.selenium.support.PageFactory; | |
7 | - | |
8 | 3 | import com.buyer.pageObject.BuyerLoginPage; |
9 | 4 | import com.buyer.pageObject.IndexPage; |
10 | 5 | import com.essa.framework.BrowserEngine; |
11 | -import com.essa.pageObject.LoginPage; | |
6 | +import org.openqa.selenium.WebDriver; | |
7 | +import org.openqa.selenium.support.PageFactory; | |
12 | 8 | |
13 | 9 | /** |
14 | 10 | * @author Administrator |
... | ... | @@ -26,11 +22,11 @@ public class BaseTest { |
26 | 22 | */ |
27 | 23 | public void initsetUp() { |
28 | 24 | BrowserEngine browserEngine = new BrowserEngine(); |
29 | - try { | |
25 | +// try { | |
30 | 26 | browserEngine.initConfigData(); |
31 | - } catch (IOException e) { | |
27 | + /*} catch (IOException e) { | |
32 | 28 | e.printStackTrace(); |
33 | - } | |
29 | + }*/ | |
34 | 30 | driver = browserEngine.getBrowser(); |
35 | 31 | } |
36 | 32 | |
... | ... | @@ -39,11 +35,11 @@ public class BaseTest { |
39 | 35 | */ |
40 | 36 | public void initBuyer() { |
41 | 37 | BrowserEngine browserEngine = new BrowserEngine(); |
42 | - try { | |
38 | +// try { | |
43 | 39 | browserEngine.initConfigData(); |
44 | - } catch (IOException e) { | |
40 | + /* } catch (IOException e) { | |
45 | 41 | e.printStackTrace(); |
46 | - } | |
42 | + }*/ | |
47 | 43 | driver = browserEngine.buyerGetBrowser(); |
48 | 44 | } |
49 | 45 | ... | ... |
src/main/java/com/essa/testSuite/TestDevelopmentAbility.java
1 | 1 | package com.essa.testSuite; |
2 | 2 | |
3 | -import static org.testng.Assert.assertEquals; | |
4 | - | |
5 | -import java.io.IOException; | |
6 | - | |
3 | +import com.essa.framework.SystemConstant; | |
4 | +import com.essa.pageObject.BaseTest; | |
5 | +import com.essa.pageObject.HomePage; | |
6 | +import com.essa.pageObject.SupplierOperationsTrackPage; | |
7 | +import com.essa.pageObject.SupplierStrengthPage; | |
7 | 8 | import org.openqa.selenium.WebDriver; |
8 | 9 | import org.openqa.selenium.support.PageFactory; |
9 | 10 | import org.testng.annotations.AfterClass; |
... | ... | @@ -12,10 +13,9 @@ import org.testng.annotations.DataProvider; |
12 | 13 | import org.testng.annotations.Test; |
13 | 14 | import org.testng.asserts.SoftAssert; |
14 | 15 | |
15 | -import com.essa.pageObject.HomePage; | |
16 | -import com.essa.pageObject.SupplierOperationsTrackPage; | |
17 | -import com.essa.pageObject.SupplierStrengthPage; | |
18 | -import com.essa.pageObject.BaseTest; | |
16 | +import java.io.IOException; | |
17 | + | |
18 | +import static org.testng.Assert.assertEquals; | |
19 | 19 | |
20 | 20 | public class TestDevelopmentAbility extends BaseTest { |
21 | 21 | |
... | ... | @@ -102,7 +102,7 @@ public class TestDevelopmentAbility extends BaseTest { |
102 | 102 | |
103 | 103 | try { |
104 | 104 | |
105 | - return com.essa.framework.BasePage.readExcel(".\\src\\main\\resources", "data.xlsx", "供应商"); | |
105 | + return com.essa.framework.BasePage.readExcel(SystemConstant.RESOURCE_PATH, "data.xlsx", "供应商"); | |
106 | 106 | |
107 | 107 | } catch (Exception e) { |
108 | 108 | ... | ... |
src/main/java/com/essa/testSuite/TestLogin.java
1 | 1 | package com.essa.testSuite; |
2 | 2 | |
3 | -import java.io.IOException; | |
4 | - | |
3 | +import com.essa.framework.BrowserEngine; | |
4 | +import com.essa.framework.SystemConstant; | |
5 | +import com.essa.pageObject.HomePage; | |
6 | +import com.essa.pageObject.LoginPage; | |
5 | 7 | import org.openqa.selenium.WebDriver; |
6 | 8 | import org.openqa.selenium.support.PageFactory; |
7 | 9 | import org.testng.annotations.AfterClass; |
... | ... | @@ -10,9 +12,7 @@ import org.testng.annotations.DataProvider; |
10 | 12 | import org.testng.annotations.Test; |
11 | 13 | import org.testng.asserts.SoftAssert; |
12 | 14 | |
13 | -import com.essa.framework.BrowserEngine; | |
14 | -import com.essa.pageObject.HomePage; | |
15 | -import com.essa.pageObject.LoginPage; | |
15 | +import java.io.IOException; | |
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @author Administrator |
... | ... | @@ -80,7 +80,7 @@ public class TestLogin { |
80 | 80 | |
81 | 81 | try { |
82 | 82 | |
83 | - return com.essa.framework.BasePage.readExcel(".\\src\\main\\resources", "data.xlsx", "users"); | |
83 | + return com.essa.framework.BasePage.readExcel(SystemConstant.RESOURCE_PATH, "data.xlsx", "users"); | |
84 | 84 | |
85 | 85 | } catch (Exception e) { |
86 | 86 | ... | ... |
src/main/java/swing/SwingMain.java
1 | 1 | package swing; |
2 | 2 | |
3 | -import java.awt.EventQueue; | |
4 | - | |
5 | -import javax.swing.JFrame; | |
6 | -import javax.swing.ButtonGroup; | |
7 | -import javax.swing.JButton; | |
8 | -import java.awt.event.ActionListener; | |
9 | -import java.io.BufferedReader; | |
10 | -import java.io.File; | |
11 | -import java.io.FileInputStream; | |
12 | -import java.io.FileNotFoundException; | |
13 | -import java.io.FileOutputStream; | |
14 | -import java.io.IOException; | |
15 | -import java.io.InputStream; | |
16 | -import java.io.InputStreamReader; | |
17 | -import java.io.RandomAccessFile; | |
18 | -import java.io.StringReader; | |
19 | -import java.text.SimpleDateFormat; | |
20 | -import java.util.ArrayList; | |
21 | -import java.util.Date; | |
22 | -import java.util.List; | |
23 | -import java.util.Properties; | |
24 | -import java.util.concurrent.Executors; | |
25 | -import java.util.concurrent.ScheduledExecutorService; | |
26 | -import java.util.concurrent.TimeUnit; | |
27 | -import java.awt.event.ActionEvent; | |
28 | -import javax.swing.JTextField; | |
29 | - | |
30 | -import org.apache.xmlbeans.impl.xb.xsdschema.Public; | |
3 | +import com.essa.framework.*; | |
4 | +import com.essa.pageObject.GoodsManage.AddOriginalGoodsPage; | |
5 | +import com.essa.pageObject.GoodsManage.UpdatePicPage; | |
31 | 6 | import org.jdom.Document; |
32 | 7 | import org.jdom.Element; |
33 | 8 | import org.jdom.JDOMException; |
... | ... | @@ -35,47 +10,20 @@ import org.jdom.input.SAXBuilder; |
35 | 10 | import org.jdom.output.XMLOutputter; |
36 | 11 | import org.testng.TestNG; |
37 | 12 | |
38 | -import com.essa.framework.BrowserEngine; | |
39 | -import com.essa.framework.Logger; | |
40 | -import com.essa.framework.Model; | |
41 | -import com.essa.pageObject.GoodsManage.AddOriginalGoodsPage; | |
42 | -import com.essa.pageObject.GoodsManage.GoodsBankPage; | |
43 | -import com.essa.pageObject.GoodsManage.UpdatePicPage; | |
44 | - | |
45 | -import javax.swing.JLabel; | |
46 | -import javax.swing.JRadioButton; | |
47 | -import javax.swing.JComboBox; | |
48 | -import javax.swing.JFileChooser; | |
49 | -import javax.swing.JScrollPane; | |
50 | -import javax.swing.JTextArea; | |
51 | - | |
52 | -import java.awt.Color; | |
53 | -import javax.swing.DefaultComboBoxModel; | |
54 | -import javax.swing.ImageIcon; | |
55 | -import java.awt.Toolkit; | |
56 | -import java.awt.BorderLayout; | |
57 | -import java.awt.Choice; | |
58 | -import java.awt.Font; | |
59 | -import java.awt.Graphics; | |
60 | - | |
61 | -import javax.swing.JList; | |
62 | -import javax.swing.JMenuBar; | |
63 | -import javax.swing.JTextPane; | |
64 | -import java.awt.event.InputMethodListener; | |
65 | -import java.awt.event.InputMethodEvent; | |
66 | -import java.beans.VetoableChangeListener; | |
67 | -import java.beans.PropertyChangeEvent; | |
68 | -import javax.swing.JPanel; | |
69 | -import java.beans.PropertyChangeListener; | |
13 | +import javax.swing.*; | |
14 | +import javax.swing.border.LineBorder; | |
15 | +import java.awt.*; | |
16 | +import java.awt.event.ActionEvent; | |
17 | +import java.awt.event.ActionListener; | |
70 | 18 | import java.awt.event.MouseAdapter; |
71 | 19 | import java.awt.event.MouseEvent; |
72 | -import javax.swing.UIManager; | |
73 | -import java.awt.TextField; | |
74 | -import java.awt.Panel; | |
75 | -import javax.swing.JScrollBar; | |
76 | -import javax.swing.ScrollPaneConstants; | |
77 | -import javax.swing.SwingWorker; | |
78 | -import javax.swing.border.LineBorder; | |
20 | +import java.io.File; | |
21 | +import java.io.FileOutputStream; | |
22 | +import java.io.IOException; | |
23 | +import java.text.SimpleDateFormat; | |
24 | +import java.util.ArrayList; | |
25 | +import java.util.Date; | |
26 | +import java.util.List; | |
79 | 27 | |
80 | 28 | /** |
81 | 29 | * @author Administrator 图形化 |
... | ... | @@ -130,7 +78,7 @@ public class SwingMain { |
130 | 78 | public void initData() { |
131 | 79 | try { |
132 | 80 | SAXBuilder builder = new SAXBuilder(); |
133 | - Document document = builder.build(new File(".\\resources\data.xml")); | |
81 | + Document document = builder.build(new File(SystemConstant.RESOURCE_PATH + "\data.xml")); | |
134 | 82 | Element root = document.getRootElement(); |
135 | 83 | Element element = root.getChild("data"); |
136 | 84 | this.buyerAccount = element.getChildText("buyerAccount"); |
... | ... | @@ -151,12 +99,12 @@ public class SwingMain { |
151 | 99 | public void setData(String key,String value) { |
152 | 100 | try { |
153 | 101 | SAXBuilder builder = new SAXBuilder(); |
154 | - Document document = builder.build(new File(".\\resources\data.xml")); | |
102 | + Document document = builder.build(new File(SystemConstant.RESOURCE_PATH + "\data.xml")); | |
155 | 103 | Element root = document.getRootElement(); |
156 | 104 | Element element = root.getChild("data"); |
157 | 105 | element.getChild(key).setText(value); |
158 | 106 | XMLOutputter XMLOut = new XMLOutputter(); |
159 | - XMLOut.output(document,new FileOutputStream(".\\resources\data.xml")); | |
107 | + XMLOut.output(document,new FileOutputStream(SystemConstant.RESOURCE_PATH + "\data.xml")); | |
160 | 108 | } catch (Exception e) { |
161 | 109 | e.printStackTrace(); |
162 | 110 | } |
... | ... | @@ -309,10 +257,13 @@ public class SwingMain { |
309 | 257 | } |
310 | 258 | }); |
311 | 259 | selectSystem.setFont(new Font("微软雅黑", Font.PLAIN, 14)); |
312 | - selectSystem.addItem("SIT"); | |
260 | + for (EnvEnum envEnum : EnvEnum.values()) { | |
261 | + selectSystem.addItem(envEnum.getCode()); | |
262 | + } | |
263 | + /* selectSystem.addItem("SIT"); | |
313 | 264 | selectSystem.addItem("HOTFIX"); |
314 | 265 | selectSystem.addItem("UAT"); |
315 | - selectSystem.addItem("DIT"); | |
266 | + selectSystem.addItem("DIT");*/ | |
316 | 267 | frmvBy.getContentPane().add(selectSystem); |
317 | 268 | |
318 | 269 | //添加市场商品 |
... | ... | @@ -615,48 +566,58 @@ public class SwingMain { |
615 | 566 | if (Scene == "新增原厂商品") { |
616 | 567 | AddOriginalGoodsPage.setSupplierName(supplierName.getText()); |
617 | 568 | UpdatePicPage.setPicPath(picPath.getText()); |
618 | - suites.add(".\\resources\\suites\\addOriginalGoods.xml");// 图形界面 | |
569 | + suites.add(SuitesEnum.ADD_ORIGINAL_GOODS.getSuiteName()); | |
570 | +// suites.add(".\\resources\\suites\\addOriginalGoods.xml");// 图形界面 | |
619 | 571 | } else if (Scene == "新增市场商品") { |
620 | 572 | Model.setBuyerNo(buyerNo2.getText()); |
621 | 573 | Model.setPicPath(picPath.getText()); |
622 | 574 | Model.setSupplierName(supplierName.getText()); |
623 | - suites.add(".\\resources\\suites\\addMarketGoods.xml");// 图形界面 | |
575 | + suites.add(SuitesEnum.ADD_MARKET_GOODS.getSuiteName()); | |
576 | +// suites.add(".\\resources\\suites\\addMarketGoods.xml");// 图形界面 | |
624 | 577 | } else if (Scene == "发布团购") { |
625 | 578 | AddOriginalGoodsPage.setSupplierName(supplierName.getText()); |
626 | 579 | UpdatePicPage.setPicPath(picPath.getText()); |
627 | - suites.add(".\\resources\\suites\\publishGroupPurchase.xml");// 图形界面 | |
580 | + suites.add(SuitesEnum.PUBLISH_GROUP_PURCHASE.getSuiteName()); | |
581 | +// suites.add(".\\resources\\suites\\publishGroupPurchase.xml");// 图形界面 | |
628 | 582 | } else if (Scene == "采购商注册") { |
629 | 583 | if (!(registerAccount.getText().equals("") |
630 | 584 | || registerAccount.getText().equals("若不填写将自动生成"))) { |
631 | 585 | Model.setEmail(registerAccount.getText()); |
632 | 586 | } |
633 | - suites.add(".\\resources\\suites\\buyerRegister.xml");// 图形界面 | |
587 | + suites.add(SuitesEnum.BUYER_REGISTER.getSuiteName()); | |
588 | +// suites.add(".\\resources\\suites\\buyerRegister.xml");// 图形界面 | |
634 | 589 | } else if (Scene == "添加SKU至购物车") {// 暂时舍弃 |
635 | 590 | Model.setBuyerAccount(account.getText()); |
636 | 591 | Model.setBuyerPassword(password.getText()); |
637 | 592 | Model.setSkuNo(SkuNo.getText()); |
638 | - suites.add(".\\resources\\suites\\addSkuToCart.xml"); | |
593 | + suites.add(SuitesEnum.ADD_SKU_TO_CART.getSuiteName()); | |
594 | +// suites.add(".\\resources\\suites\\addSkuToCart.xml"); | |
639 | 595 | } else if (Scene == "成品询价") { |
640 | 596 | Model.setBuyerAccount(account.getText()); |
641 | 597 | Model.setBuyerPassword(password.getText()); |
642 | 598 | Model.setSkuNo(SkuNo.getText()); |
643 | 599 | if (Model.getIsactivity() == 1) { |
644 | - suites.add(".\\resources\\suites\\activityInquiry.xml"); | |
600 | + suites.add(SuitesEnum.ACTIVITY_INQUIRY.getSuiteName()); | |
601 | +// suites.add(".\\resources\\suites\\activityInquiry.xml"); | |
645 | 602 | }else { |
646 | - suites.add(".\\resources\\suites\\productInquiry.xml"); | |
603 | + suites.add(SuitesEnum.PRODUCT_INQUIRY.getSuiteName()); | |
604 | +// suites.add(".\\resources\\suites\\productInquiry.xml"); | |
647 | 605 | } |
648 | 606 | } else if (Scene == "生成PO") { |
649 | 607 | Model.setBuyerAccount(account.getText()); |
650 | 608 | Model.setBuyerPassword(password.getText()); |
651 | 609 | Model.setSkuNo(SkuNo.getText()); |
652 | 610 | if (Model.getIsactivity() == 1) { |
653 | - suites.add(".\\resources\\suites\\activitySendPO.xml"); | |
611 | + suites.add(SuitesEnum.ACTIVITY_SEND_PO.getSuiteName()); | |
612 | +// suites.add(".\\resources\\suites\\activitySendPO.xml"); | |
654 | 613 | }else { |
655 | - suites.add(".\\resources\\suites\\sendPO.xml"); | |
614 | + suites.add(SuitesEnum.SEND_PO.getSuiteName()); | |
615 | +// suites.add(".\\resources\\suites\\sendPO.xml"); | |
656 | 616 | } |
657 | 617 | } else if (Scene == "PO询价") { |
658 | 618 | Model.setPoNum(po.getText()); |
659 | - suites.add(".\\resources\\suites\\POInquiry.xml"); | |
619 | + suites.add(SuitesEnum.PO_INQUIRY.getSuiteName()); | |
620 | +// suites.add(".\\resources\\suites\\POInquiry.xml"); | |
660 | 621 | } |
661 | 622 | testNG.setTestSuites(suites); |
662 | 623 | testNG.run(); | ... | ... |
src/main/resources/conf/config_dit.properties
src/main/resources/conf/config_hotfix.properties
src/main/resources/conf/config_uat.properties
... | ... | @@ -2,15 +2,6 @@ |
2 | 2 | #browserName=IE |
3 | 3 | browserName=Chrome |
4 | 4 | |
5 | -SIT=http://bpms.sit.gz.essa | |
6 | -BSIT=http://en.portalsit.cn | |
7 | - | |
8 | -HOTFIX=http://bpms.hotfix.gz.essa | |
9 | -BHOTFIX=http://en.portalhotfix.cn | |
10 | - | |
11 | -UAT=http://bpms.spstoys.com:7291 | |
12 | -BUAT=http://en.spstoys.com:889 | |
13 | - | |
14 | -DIT=http://bpms.dit.gz.essa | |
15 | -BDIT=http://en.portaldit.cn | |
5 | +serverURL=http://bpms.spstoys.com:7291 | |
6 | +buyerURL=http://en.spstoys.com:889 | |
16 | 7 | ... | ... |