Verifies issue 37921 : Added automated test 'I37921_VerifyKeyboardOnCashup'
authorRanjith S R <ranjith@qualiantech.com>
Sun, 18 Feb 2018 14:31:02 +0530
changeset 7192 87f366a9ca71
parent 7078 0a24b59e81a2
child 7193 724b579bc134
Verifies issue 37921 : Added automated test 'I37921_VerifyKeyboardOnCashup'
src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I37921_VerifyKeyboardOnCashup.java
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java	Thu Feb 15 12:58:24 2018 +0100
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java	Sun Feb 18 14:31:02 2018 +0530
@@ -2003,6 +2003,8 @@
       EnyoKind.BUTTON); //
   public static TestIdConstructor BUTTON_CASHUP_PREVIOUS = new TestIdConstructor(
       "theButton_btnPrevious", EnyoKind.BUTTON); //
+  public static TestIdConstructor INPUT_KEYPAD_CASHUP_EDITBOX = new TestIdConstructor(
+      "cashUpKeyboard_editbox"); //
   public static TestIdConstructor LABEL_CASHUP_STEP1_TITLE = new TestIdConstructor(
       "listPendingReceipts_stepsheader"); //
   public static TestIdConstructor LABEL_CASHUP_STEP1_FIRST_PENDING_TICKET = new TestIdConstructor(
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I37921_VerifyKeyboardOnCashup.java	Sun Feb 18 14:31:02 2018 +0530
@@ -0,0 +1,91 @@
+/*
+ *************************************************************************
+ * 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) 2018 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAN
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.system;
+
+import org.junit.Test;
+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.pack.selenium.TestIdPack;
+import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
+import org.openqa.selenium.Keys;
+
+public class I37921_VerifyKeyboardOnCashup extends WebPOSTerminalHelper {
+
+  final String validUPCEAN = "123.00/";
+  final String validAmount = "123.00";
+  final String vbsTerminalTypeId = "BD39916225594B32A88983899CF05F72";
+
+  @Test
+  public void test() {
+    pressKeys();
+    verify(TestIdPack.INPUT_POINTOFSALE, validUPCEAN);
+    write(TestIdPack.INPUT_POINTOFSALE, "");
+
+    tap(TestIdPack.BUTTON_MENU);
+    tap(TestIdPack.BUTTON_MENU_CASHUP);
+    verify(TestIdPack.LABEL_CASHUP_STEP2_TITLE, "Step 1 of 4: Count Cash");
+    pressKeys();
+    verify(TestIdPack.INPUT_KEYPAD_CASHUP_EDITBOX, validAmount);
+    write(TestIdPack.INPUT_KEYPAD_CASHUP_EDITBOX, "");
+    tap(TestIdPack.BUTTON_CASHUP_CANCEL);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    tap(TestIdPack.BUTTON_MENU);
+    tap(TestIdPack.BUTTON_MENU_CASHMANAGEMENT);
+    verify(TestIdPack.LABEL_CASHMANAGEMENT_TITLE, "Cash Management");
+    pressKeys();
+    verify(TestIdPack.INPUT_KEYPAD_CASHMGMT_EDITBOX, validAmount);
+    write(TestIdPack.INPUT_KEYPAD_CASHMGMT_EDITBOX, "");
+    tap(TestIdPack.BUTTON_CASHMANAGEMENT_CANCEL);
+
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void pressKeys() {
+    SeleniumHelper.pressKey(Keys.NUMPAD1);
+    SeleniumHelper.pressKey(Keys.NUMPAD2);
+    SeleniumHelper.pressKey(Keys.NUMPAD3);
+    SeleniumHelper.pressKey(Keys.DECIMAL);
+    SeleniumHelper.pressKey(Keys.NUMPAD0);
+    SeleniumHelper.pressKey(Keys.NUMPAD0);
+    SeleniumHelper.pressKey(Keys.DIVIDE);
+    OBUtils.pause(200);
+  }
+
+  @Override
+  public void beforeWithReload() {
+    changeUseExternalInput(true);
+  }
+
+  @Override
+  public void afterWithReload() {
+    changeUseExternalInput(false);
+  }
+
+  private void changeUseExternalInput(final boolean isForTest) {
+    final String sql = String.format("UPDATE obpos_terminaltype SET usebarcodescanner = '%s' "
+        + "WHERE obpos_terminaltype_id = '%s'", isForTest ? "Y" : "N", vbsTerminalTypeId);
+    new DatabaseHelperInsertUpdateOrDelete().execute(sql, 1);
+  }
+}
\ No newline at end of file