[AWO Tests] Trying to stabilize Scan tests
authorAlejandro <alekosmp86@gmail.com>
Fri, 17 May 2019 09:25:07 -0400
changeset 8542 6ca36b6d0d18
parent 8541 e1ba59106b45
child 8543 bf120555e05d
[AWO Tests] Trying to stabilize Scan tests
src-test/org/openbravo/test/mobile/awo/tests/Scan/AWO_VerifyBinScanWhileBoxProcess.java
src-test/org/openbravo/test/mobile/awo/tests/Scan/AWO_VerifyBinScanWhileBoxUnboxProcess.java
src-test/org/openbravo/test/mobile/awo/tests/Scan/AWO_VerifyBinScanWhileUnboxProcess.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/awo/tests/Scan/AWO_VerifyBinScanWhileBoxProcess.java	Fri May 17 09:25:07 2019 -0400
@@ -0,0 +1,133 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2019 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author alekosmp86
+ *
+ */
+
+package org.openbravo.test.mobile.awo.tests.Scan;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.apache.commons.codec.binary.StringUtils;
+import org.junit.Test;
+import org.openbravo.test.mobile.awo.utilities.AWOTerminalHelper;
+import org.openbravo.test.mobile.awo.utilities.TestIdAwo;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.core.utils.OBUtils;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect.RecordsCount;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.TestRegistryHelper;
+import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
+import org.openbravo.test.mobile.retail.mobilecore.utils.ApplicationWindow;
+import org.openqa.selenium.Keys;
+
+public class AWO_VerifyBinScanWhileBoxProcess extends AWOTerminalHelper {
+  final private String SHP301_LOCATOR_ID = "11DFB1B220B44B5DBA51B8C6096FDD5F";
+  final private String SHP301_BARCODE = "112233";
+  final private String PRODUCT_NAME = "Havana Club Rum";
+
+  @Test
+  public void test() {
+    tap(TestIdAwo.BUTTON_MENU);
+    tap(TestIdAwo.BUTTON_MENU_BOX);
+    verify(TestIdAwo.REFINV_SELECT_REFERENCE_HEADER, "Select Reference");
+    // create a new reference
+    tap(TestIdAwo.REFINV_CREATENEW_REF);
+    tap(TestIdAwo.REFINV_REFTYPE_SELECTOR);
+    write(TestIdAwo.REFINV_REFTYPE_SELECTORLIST_INPUT, "Sequenced Container");
+    tap(TestIdAwo.REFINV_REFTYPE_SELECTORLIST_SEARCH);
+    tap(TestIdAwo.REFINV_REFTYPE_SELECTORLIST_ROW1);
+    tap(TestIdAwo.REFINV_GENERATE_REF_BUTTON);
+    tap(TestIdAwo.REFINV_CREATEANDBOXUNBOX_BUTTON);
+
+    // verify the reference was created without a defined locator
+    assertThat("Header should contain the string 'Unknown locator'",
+        get(TestIdAwo.REFINV_REFLOCATOR_HEADER).contains("(Unknown Locator)"));
+
+    // add product
+    tap(TestIdAwo.REFINV_ADDPRODUCT_BUTTON);
+    write(TestIdAwo.REFINV_PRODUCT_INPUT_FILTER, PRODUCT_NAME);
+    TestIdAwo.REFINV_PRODUCT_INPUT_FILTER.enyoNode().executeExtension(".pressKey()");
+    tap(TestIdAwo.REFINV_PRODUCT_SEARCH);
+    waitForRecordsToRenderInList(TestIdAwo.REFINV_PRODUCT_LIST, 0,
+        RecordsCount.GREATER_THAN_EXPECTED);
+    isVisible(TestIdAwo.PRODUCTLIST_ROW1, true);
+    tap(TestIdAwo.PRODUCTLIST_ROW1);
+
+    // save the current (undefined) locator
+    String initialLocator = get(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE);
+    // scan barcode and compare locators
+    OBUtils.pause(1000);
+    scanBarcode();
+    SeleniumHelper.takeScreenshot("justAfterScan_BarCode");
+    TestRegistryHelper.forceRefresh();
+    String finalLocatorIdTest = getElementFullIdtest("_confirmedValue");
+    TestIdConstructor bin = new TestIdConstructor(finalLocatorIdTest);
+    String finalLocator = get(bin);
+    OBUtils.pause(1000);
+    assertThat("From Bin locator should have changed",
+        !StringUtils.equals(initialLocator, finalLocator));
+    verify(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE, "SHP301");
+
+    tap(TestIdAwo.REFINV_BACK_BUTTON);
+    tap(TestIdAwo.POPUP_CONFIRM_OKBUTTON_UP);
+    waitUntilCertainWindowIsReached(ApplicationWindow.AWO_TASKS);
+  }
+
+  @Override
+  public void beforeWithReload() {
+    setBinBarcode(SHP301_LOCATOR_ID, SHP301_BARCODE);
+  }
+
+  @Override
+  public void afterWithReload() {
+    setBinBarcode(SHP301_LOCATOR_ID, null);
+  }
+
+  private void setBinBarcode(String locatorId, String barcode) {
+    String sql = "";
+    if (!StringUtils.equals(barcode, null)) {
+      sql = String.format("update m_locator set barcode = '%s' where m_locator_id = '%s'", barcode,
+          locatorId);
+    } else {
+      sql = String.format("update m_locator set barcode = NULL where m_locator_id = '%s'",
+          locatorId);
+    }
+
+    new DatabaseHelperInsertUpdateOrDelete() {
+    }.execute(sql, 1);
+  }
+  
+  private void scanBarcode() {
+    SeleniumHelper.pressKey(Keys.NUMPAD1);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.NUMPAD1);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.NUMPAD2);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.NUMPAD2);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.NUMPAD3);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.NUMPAD3);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.ENTER);
+    OBUtils.pause(500);
+  }
+}
--- a/src-test/org/openbravo/test/mobile/awo/tests/Scan/AWO_VerifyBinScanWhileBoxUnboxProcess.java	Thu May 16 17:12:28 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License.
- * The Original Code is Openbravo ERP.
- * The Initial Developer of the Original Code is Openbravo S.L.U.
- * All portions are Copyright (C) 2019 Openbravo S.L.U.
- * All Rights Reserved.
- * Contributor(s):
- ************************************************************************
- *
- * @author alekosmp86
- *
- */
-
-package org.openbravo.test.mobile.awo.tests.Scan;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-
-import org.apache.commons.codec.binary.StringUtils;
-import org.junit.Test;
-import org.openbravo.test.mobile.awo.utilities.AWOTerminalHelper;
-import org.openbravo.test.mobile.awo.utilities.TestIdAwo;
-import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
-import org.openbravo.test.mobile.core.utils.OBUtils;
-import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
-import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect.RecordsCount;
-import org.openbravo.test.mobile.retail.mobilecore.javascript.TestRegistryHelper;
-import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
-import org.openbravo.test.mobile.retail.mobilecore.utils.ApplicationWindow;
-import org.openqa.selenium.Keys;
-
-public class AWO_VerifyBinScanWhileBoxUnboxProcess extends AWOTerminalHelper {
-  final private String SHP301_LOCATOR_ID = "11DFB1B220B44B5DBA51B8C6096FDD5F";
-  final private String SHP301_BARCODE = "112233";
-  final private String FOOD001_LOCATOR_ID = "7F3D8960E85440DABCB013F827C5528F";
-  final private String FOOD001_BARCODE = "445566";
-  final private String PRODUCT_NAME = "Havana Club Rum";
-
-  final private String UNBOX_CONTAINER = "CNT1000000";
-
-  @Test
-  public void test() {
-    tap(TestIdAwo.BUTTON_MENU);
-    tap(TestIdAwo.BUTTON_MENU_BOX);
-    verify(TestIdAwo.REFINV_SELECT_REFERENCE_HEADER, "Select Reference");
-    // create a new reference
-    tap(TestIdAwo.REFINV_CREATENEW_REF);
-    tap(TestIdAwo.REFINV_REFTYPE_SELECTOR);
-    write(TestIdAwo.REFINV_REFTYPE_SELECTORLIST_INPUT, "Sequenced Container");
-    tap(TestIdAwo.REFINV_REFTYPE_SELECTORLIST_SEARCH);
-    tap(TestIdAwo.REFINV_REFTYPE_SELECTORLIST_ROW1);
-    tap(TestIdAwo.REFINV_GENERATE_REF_BUTTON);
-    tap(TestIdAwo.REFINV_CREATEANDBOXUNBOX_BUTTON);
-
-    // verify the reference was created without a defined locator
-    assertThat("Header should contain the string 'Unknown locator'",
-        get(TestIdAwo.REFINV_REFLOCATOR_HEADER).contains("(Unknown Locator)"));
-
-    // add product
-    tap(TestIdAwo.REFINV_ADDPRODUCT_BUTTON);
-    write(TestIdAwo.REFINV_PRODUCT_INPUT_FILTER, PRODUCT_NAME);
-    TestIdAwo.REFINV_PRODUCT_INPUT_FILTER.enyoNode().executeExtension(".pressKey()");
-    tap(TestIdAwo.REFINV_PRODUCT_SEARCH);
-    waitForRecordsToRenderInList(TestIdAwo.REFINV_PRODUCT_LIST, 0,
-        RecordsCount.GREATER_THAN_EXPECTED);
-    isVisible(TestIdAwo.PRODUCTLIST_ROW1, true);
-    tap(TestIdAwo.PRODUCTLIST_ROW1);
-
-    // save the current (undefined) locator
-    String initialLocator = get(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE);
-    // scan barcode and compare locators
-    OBUtils.pause(1000);
-    scanBarcode(SHP301_BARCODE);
-    OBUtils.pause(1000);
-    SeleniumHelper.pressKey(Keys.ENTER);
-    SeleniumHelper.takeScreenshot("justAfterScan_BarCode");
-    TestRegistryHelper.forceRefresh();
-    String finalLocatorIdTest = getElementFullIdtest("_confirmedValue");
-    TestIdConstructor bin = new TestIdConstructor(finalLocatorIdTest);
-    String finalLocator = get(bin);
-    OBUtils.pause(1000);
-    assertThat("From Bin locator should have changed",
-        !StringUtils.equals(initialLocator, finalLocator));
-    verify(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE, "SHP301");
-
-    tap(TestIdAwo.REFINV_BACK_BUTTON);
-    tap(TestIdAwo.POPUP_CONFIRM_OKBUTTON_UP);
-    waitUntilCertainWindowIsReached(ApplicationWindow.AWO_TASKS);
-  }
-
-  @Test
-  public void test2() {
-    tap(TestIdAwo.BUTTON_MENU);
-    tap(TestIdAwo.BUTTON_MENU_UNBOX);
-
-    // find a reference with stock
-    write(TestIdAwo.REFINV_REFERENCE_INPUT, UNBOX_CONTAINER);
-    tap(TestIdAwo.REFINV_SELECTREFERENCE_BUTTON);
-
-    // verify that button "Unbox" appears
-    isVisible(TestIdAwo.REFINV_BOXUNBOX_BUTTON, true);
-    isDisabled(TestIdAwo.REFINV_BOXUNBOX_BUTTON, false);
-
-    // start unbox process
-    tap(TestIdAwo.REFINV_BOXUNBOX_BUTTON);
-    tap(TestIdAwo.REFINV_ADDPRODUCT_BUTTON);
-    write(TestIdAwo.REFINV_PRODUCT_INPUT_FILTER, PRODUCT_NAME);
-    TestIdAwo.REFINV_PRODUCT_INPUT_FILTER.enyoNode().executeExtension(".pressKey()");
-    tap(TestIdAwo.REFINV_PRODUCT_SEARCH);
-    waitForRecordsToRenderInList(TestIdAwo.REFINV_PRODUCT_LIST, 1, RecordsCount.SAME_AS_EXPECTED);
-    tap(TestIdAwo.REFINV_PRODUCTLIST_ROW1);
-
-    // save the current (undefined) locator
-    String initialLocator = get(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE);
-    // scan barcode and compare locators
-    OBUtils.pause(1000);
-    scanBarcode(FOOD001_BARCODE);
-    OBUtils.pause(1000);
-    SeleniumHelper.pressKey(Keys.ENTER);
-    SeleniumHelper.takeScreenshot("justAfterScan_BarCode");
-    TestRegistryHelper.forceRefresh();
-    String finalLocatorIdTest = getElementFullIdtest("_confirmedValue");
-    TestIdConstructor bin = new TestIdConstructor(finalLocatorIdTest);
-    String finalLocator = get(bin);
-    OBUtils.pause(1000);
-    assertThat("From Bin locator should have changed",
-        !StringUtils.equals(initialLocator, finalLocator));
-    verify(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE, "Food001");
-
-    tap(TestIdAwo.REFINV_BACK_BUTTON);
-    tap(TestIdAwo.POPUP_CONFIRM_OKBUTTON_UP);
-    waitUntilCertainWindowIsReached(ApplicationWindow.AWO_TASKS);
-  }
-
-  @Override
-  public void beforeWithReload() {
-    setBinBarcode(SHP301_LOCATOR_ID, SHP301_BARCODE);
-    setBinBarcode(FOOD001_LOCATOR_ID, FOOD001_BARCODE);
-  }
-
-  @Override
-  public void afterWithReload() {
-    setBinBarcode(SHP301_LOCATOR_ID, null);
-    setBinBarcode(FOOD001_LOCATOR_ID, null);
-  }
-
-  private void setBinBarcode(String locatorId, String barcode) {
-    String sql = "";
-    if (!StringUtils.equals(barcode, null)) {
-      sql = String.format("update m_locator set barcode = '%s' where m_locator_id = '%s'", barcode,
-          locatorId);
-    } else {
-      sql = String.format("update m_locator set barcode = NULL where m_locator_id = '%s'",
-          locatorId);
-    }
-
-    new DatabaseHelperInsertUpdateOrDelete() {
-    }.execute(sql, 1);
-  }
-  
-  private void scanBarcode(String barcode) {
-    SeleniumHelper.pressKeyAction(barcode);
-  }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/awo/tests/Scan/AWO_VerifyBinScanWhileUnboxProcess.java	Fri May 17 09:25:07 2019 -0400
@@ -0,0 +1,129 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2019 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author alekosmp86
+ *
+ */
+
+package org.openbravo.test.mobile.awo.tests.Scan;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.apache.commons.codec.binary.StringUtils;
+import org.junit.Test;
+import org.openbravo.test.mobile.awo.utilities.AWOTerminalHelper;
+import org.openbravo.test.mobile.awo.utilities.TestIdAwo;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.core.utils.OBUtils;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect.RecordsCount;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.TestRegistryHelper;
+import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
+import org.openbravo.test.mobile.retail.mobilecore.utils.ApplicationWindow;
+import org.openqa.selenium.Keys;
+
+public class AWO_VerifyBinScanWhileUnboxProcess extends AWOTerminalHelper {
+  final private String FOOD001_LOCATOR_ID = "7F3D8960E85440DABCB013F827C5528F";
+  final private String FOOD001_BARCODE = "445566";
+  final private String PRODUCT_NAME = "Havana Club Rum";
+
+  final private String UNBOX_CONTAINER = "CNT1000000";
+
+  @Test
+  public void test() {
+    tap(TestIdAwo.BUTTON_MENU);
+    tap(TestIdAwo.BUTTON_MENU_UNBOX);
+
+    // find a reference with stock
+    write(TestIdAwo.REFINV_REFERENCE_INPUT, UNBOX_CONTAINER);
+    tap(TestIdAwo.REFINV_SELECTREFERENCE_BUTTON);
+
+    // verify that button "Unbox" appears
+    isVisible(TestIdAwo.REFINV_BOXUNBOX_BUTTON, true);
+    isDisabled(TestIdAwo.REFINV_BOXUNBOX_BUTTON, false);
+
+    // start unbox process
+    tap(TestIdAwo.REFINV_BOXUNBOX_BUTTON);
+    tap(TestIdAwo.REFINV_ADDPRODUCT_BUTTON);
+    write(TestIdAwo.REFINV_PRODUCT_INPUT_FILTER, PRODUCT_NAME);
+    TestIdAwo.REFINV_PRODUCT_INPUT_FILTER.enyoNode().executeExtension(".pressKey()");
+    tap(TestIdAwo.REFINV_PRODUCT_SEARCH);
+    waitForRecordsToRenderInList(TestIdAwo.REFINV_PRODUCT_LIST, 1, RecordsCount.SAME_AS_EXPECTED);
+    tap(TestIdAwo.REFINV_PRODUCTLIST_ROW1);
+
+    // save the current (undefined) locator
+    String initialLocator = get(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE);
+    // scan barcode and compare locators
+    OBUtils.pause(1000);
+    scanBarcode();
+    SeleniumHelper.takeScreenshot("justAfterScan_BarCode");
+    TestRegistryHelper.forceRefresh();
+    String finalLocatorIdTest = getElementFullIdtest("_confirmedValue");
+    TestIdConstructor bin = new TestIdConstructor(finalLocatorIdTest);
+    String finalLocator = get(bin);
+    OBUtils.pause(1000);
+    assertThat("From Bin locator should have changed",
+        !StringUtils.equals(initialLocator, finalLocator));
+    verify(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE, "Food001");
+
+    tap(TestIdAwo.REFINV_BACK_BUTTON);
+    tap(TestIdAwo.POPUP_CONFIRM_OKBUTTON_UP);
+    waitUntilCertainWindowIsReached(ApplicationWindow.AWO_TASKS);
+  }
+
+  @Override
+  public void beforeWithReload() {
+    setBinBarcode(FOOD001_LOCATOR_ID, FOOD001_BARCODE);
+  }
+
+  @Override
+  public void afterWithReload() {
+    setBinBarcode(FOOD001_LOCATOR_ID, null);
+  }
+
+  private void setBinBarcode(String locatorId, String barcode) {
+    String sql = "";
+    if (!StringUtils.equals(barcode, null)) {
+      sql = String.format("update m_locator set barcode = '%s' where m_locator_id = '%s'", barcode,
+          locatorId);
+    } else {
+      sql = String.format("update m_locator set barcode = NULL where m_locator_id = '%s'",
+          locatorId);
+    }
+
+    new DatabaseHelperInsertUpdateOrDelete() {
+    }.execute(sql, 1);
+  }
+  
+  private void scanBarcode() {
+    SeleniumHelper.pressKey(Keys.NUMPAD4);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.NUMPAD4);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.NUMPAD5);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.NUMPAD5);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.NUMPAD6);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.NUMPAD6);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.ENTER);
+    OBUtils.pause(500);    
+  }
+}