diff --git a/essa.iml b/essa.iml new file mode 100644 index 0000000..014cd5a --- /dev/null +++ b/essa.iml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/essa/framework/LinkSQL.java b/src/main/java/com/essa/framework/LinkSQL.java new file mode 100644 index 0000000..e250ca7 --- /dev/null +++ b/src/main/java/com/essa/framework/LinkSQL.java @@ -0,0 +1,60 @@ +package com.essa.framework; +import java.sql.*; + +public class LinkSQL { + + public static void main(String[] args) { + LinkSQL dao = new LinkSQL(); + dao.SQLQuery(); + + } + + public static String SQLQuery() { + + String Code = null; + Connection conn = null; + Statement stmt = null; + ResultSet rs = null; + + try { + Class.forName("com.mysql.jdbc.Driver"); +// 连接SIT环境的数据库 + conn = DriverManager.getConnection("jdbc:mysql://192.168.1.247:3307/bpms","root","redhat"); + + stmt = conn.createStatement(); + +// 查询FO单在制单中的PO单号 + 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"); + + while (rs.next()) { + Code = rs.getString("code"); + } + return Code; + + } catch (ClassNotFoundException e) { + System.out.println("驱动类无法找到!"); + throw new RuntimeException(e); + + } catch (SQLException e) { + System.out.println("数据库访问异常!"); + throw new RuntimeException(e); + }finally { + //关闭链接资源 + try { + if (rs !=null) { + rs.close(); + } + if (stmt !=null) { + stmt.cancel(); + } + if (conn !=null) { + conn.close(); + } + + } catch (SQLException e) { + System.out.println("关闭连接时发生异常"); + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/com/essa/pageObject/HomePage.java b/src/main/java/com/essa/pageObject/HomePage.java index 2f5792a..dc79f7c 100644 --- a/src/main/java/com/essa/pageObject/HomePage.java +++ b/src/main/java/com/essa/pageObject/HomePage.java @@ -1,6 +1,7 @@ package com.essa.pageObject; -import org.openqa.selenium.WebDriver; +import com.essa.pageObject.ReceiptCore.ReceiptCorePage; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.essa.framework.BasePage; @@ -157,6 +158,10 @@ public class HomePage extends BasePage{ //PO跟单 @FindBy (xpath ="//*[text()='PO跟单']") WebElement PODocumentary; + + //前台发单中心 + @FindBy (xpath ="//*[text()='前台发单中心']") + WebElement Receipt_core ; //仓储管理 @FindBy (xpath = "//span[contains(text(),'仓储管理')]") @@ -426,4 +431,13 @@ public class HomePage extends BasePage{ switchMoreWindow(); return new NeedDealtApplyPage(driver); } + + /* + * 进入前台发单中心页面 + * */ + public ReceiptCorePage toReceiptCore() { + click(DocumentaryManage); + click(Receipt_core); + return new ReceiptCorePage(driver); + } } \ No newline at end of file diff --git a/src/main/java/com/essa/pageObject/ReceiptCore/ReceiptCorePage.java b/src/main/java/com/essa/pageObject/ReceiptCore/ReceiptCorePage.java new file mode 100644 index 0000000..cbd92d9 --- /dev/null +++ b/src/main/java/com/essa/pageObject/ReceiptCore/ReceiptCorePage.java @@ -0,0 +1,177 @@ +package com.essa.pageObject.ReceiptCore; +import com.essa.framework.BasePage; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + + +/* + * 前台发单中心页面 + * */ + + +public class ReceiptCorePage extends BasePage { + + public ReceiptCorePage(WebDriver driver) { super(driver);} + + /* + * 页面元素定位 + * */ + + @FindBy (xpath = "//i[@class='iconfont icon-double-arrow-right']") +// @FindBy (xpath = "//*[contains(text(),'高级查询')]") + WebElement advancedQuery; //高级查询 + + @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]") +// @FindBy (xpath = "//input[@type='text' and @ng-model='query.params.poCode']") + + WebElement PO_numbers; //PO单号 + + @FindBy (xpath = "//*[text()='查询']") +// @FindBy (xpath = "//*/button[@type='submit']") + + WebElement Query ; //查询 + + @FindBy (xpath = "//tbody//tr[1]") +// @FindBy (xpath = "//*[@id=\"frontSendListCtrlView\"]/div/div/table/tbody/tr[1]") + + WebElement list_1; //列表第一条数据 + + @FindBy (xpath = "/html[1]/body[1]/div[2]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/table[1]/tbody[1]") + + WebElement list; //列表 + + @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]") + + WebElement document_code; //单据编号 + + @FindBy (xpath = "//*[text()='开始发单']") +// @FindBy (xpath = "/html[1]/body[1]/div[2]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/button[1]") + + WebElement start_billing; // 开始发单 + + @FindBy (xpath = "//button[@class='btn btn-danger ng-scope']") + + WebElement start_billing_1 ; //前台发单扫码平台的开始发单 + + @FindBy (xpath = "//div[@class='input-group ng-isolate-scope ng-pristine ng-valid']//input[@type='text']") + + WebElement input_document_code;//单据编号输入框 + + @FindBy (xpath = "//button[@type='button' and @ng-click='clickBtn()']") +// @FindBy (xpath = "//*[contains(@ng-click,'clickBtn')]") + + WebElement search ;// 搜索按钮 + + @FindBy (xpath = "//a[contains(text(),'扫码确认接单')]") + + WebElement Confirm_billing ; // 扫码确认接单 + + @FindBy (xpath = "//*[text()='接单完成']") + + WebElement finish_billing; //接单完成 + + @FindBy (xpath = "//*[contains(text(),'所选的工厂订单状态必须为“制单中”或“重新发单”')]") + + WebElement Fail_billing; //发单失败 + + @FindBy (xpath = "//*[contains(text(),'所选的工厂订单状态必须为“发单中”')]") + + //*[coantains(text(),'所选的工厂订单状态必须为'] + // *[@data-notify='message'] + //*[@data-notify='message'] and text()='所选的工厂订单状态必须为“发单中”' + //*[(text()=' 所选的工厂订单状态必须为“发单中”'] + + WebElement Fail_order; //接单失败 + + @FindBy (xpath = "//*[contains(text(),'操作成功')]") + + WebElement Succeed_billing; //发单成功 + + + + + + /* + * 页面方法 + * */ + + public void BillOrder(String PO_Code) { + click(advancedQuery); + forceWait(1000); + + sendKeys(PO_numbers,PO_Code); + forceWait(1000); + + click(Query); +// forceWait(3000); + + 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]")); + +// actionDoubleClick(document_code); // 双击元素 +// forceWait(1000); + String Fo = document_code.getText(); + forceWait(1000); + + click(start_billing); + forceWait(1000); + sendKeys(input_document_code,Fo); + forceWait(1000); + + click(search); + forceWait(1000); + + click(start_billing_1); + forceWait(1000); +// isVisibility(By.xpath("//*[contains(text(),'所选的工厂订单状态必须为“发单中”')]")); + + click(start_billing); + forceWait(1000); + + click(Confirm_billing); + forceWait(1000); + + sendKeys(input_document_code,Fo); + forceWait(1000); + + click(search); + forceWait(1000); + + click(finish_billing); + forceWait(3000); + + + + } + + + /* + *用于断言发单接单是否成功 + * @return boolean + */ + + public boolean isSucceed() {return isElementExist(Succeed_billing);} + + /* + *用于断言发单是否成功 + * @return boolean + */ + + public boolean FailBilling() {return isElementExist(Fail_billing);} + + /* + *用于断言接单是否成功 + * @return boolean + */ + + + public boolean FailOrder() {return isElementExist(Fail_order);} + + + + + + + +} diff --git a/src/main/java/com/essa/testSuite/TestReceiptCore.java b/src/main/java/com/essa/testSuite/TestReceiptCore.java new file mode 100644 index 0000000..86de910 --- /dev/null +++ b/src/main/java/com/essa/testSuite/TestReceiptCore.java @@ -0,0 +1,51 @@ +package com.essa.testSuite; +import com.essa.framework.LinkSQL; +import com.essa.pageObject.BaseTest; +import com.essa.pageObject.HomePage; +import com.essa.pageObject.ReceiptCore.ReceiptCorePage; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.PageFactory; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.testng.asserts.SoftAssert; + + +public class TestReceiptCore extends BaseTest { + WebDriver driver ; + + @BeforeClass + public void setUp() { + initsetUp(); + loginValid("zhidanbu"); + } + + @AfterClass + public void tearDown() {driver.quit();} + + /* + * PO发单接单 + * */ + @Test( ) + public void receiptcore () { + this.driver = getDriver(); + HomePage homePage = PageFactory.initElements(driver,HomePage.class); + homePage.toReceiptCore(); + ReceiptCorePage receiptCorePage = PageFactory.initElements(driver,ReceiptCorePage.class); + String PO = LinkSQL.SQLQuery(); + + receiptCorePage.BillOrder(PO); + + SoftAssert softAssert = new SoftAssert(); + boolean SucceedElement = receiptCorePage.isSucceed(); +// boolean FailElement = receiptCorePage.FailBilling(); +// boolean FailElement1 = receiptCorePage.FailOrder(); + System.out.println(SucceedElement); + + softAssert.assertEquals(SucceedElement,true,"发单接单失败"); + softAssert.assertAll(); + + + } + +} -- libgit2 0.21.2