Attached Files | jMeterRecordingWorkloadTest_patch2.diff [^] (10,571 bytes) 2018-10-03 17:24 [Show Content] [Hide Content]diff --git a/src-test/org/openbravo/test/mobile/retail/example/selenium/tests/jmeterrecording/WebPOSWorkloadTest.java b/src-test/org/openbravo/test/mobile/retail/example/selenium/tests/jmeterrecording/WebPOSWorkloadTest.java
new file mode 100644
--- /dev/null
+++ b/src-test/org/openbravo/test/mobile/retail/example/selenium/tests/jmeterrecording/WebPOSWorkloadTest.java
@@ -0,0 +1,268 @@
+/*
+ *************************************************************************
+ * 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 inaki_garcia
+ *
+ */
+
+package org.openbravo.test.mobile.retail.example.selenium.tests.jmeterrecording;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.core.utils.OBUtils;
+import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
+import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.SynchronizationMonitor;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSJMeterTerminalHelper;
+
+/**
+ * Test case for JMeter test script recording
+ *
+ */
+@TestClassAnnotations(isHighVolumeCompatible = true)
+public class WebPOSWorkloadTest extends WebPOSJMeterTerminalHelper {
+
+ @Test
+ public void test() {
+ final long timeinMillis = System.currentTimeMillis();
+ final String customerName = "C_" + timeinMillis;
+ final String customerDefaultAddrName = "CAB_" + timeinMillis;
+ String ticketId;
+
+ /** createBPartner **/
+ tap(TestIdPack.BUTTON_RECEIPT_CUSTOMER);
+ tap(TestIdPack.BUTTON_CUSTOMER_NEW);
+ OBUtils.pause(5000);
+ write(TestIdPack.FIELD_CUSTOMER_NAME, customerName);
+ // tap(TestIdPack.FIELD_CUSTOMER_CUSTOMER_COUNTRY_VIEW);
+ // tap(TestIdPack.FIELD_CUSTOMER_ADDRESS_INV_NAME);
+ write(TestIdPack.FIELD_CUSTOMER_ADDRESS_INV_NAME, customerDefaultAddrName);
+ tap(TestIdPack.BUTTON_CUSTOMER_SAVE);
+ // OBUtils.pause(OBConstants.WAIT_FORDATABASESYNCHRONIZATION);
+ SynchronizationMonitor.waitUntiTheApplicationHasSynchronized();
+ tap(TestIdPack.BUTTON_CUSTOMER_DETAILS_CLOSE);
+
+ /** searchBPartner **/
+ SynchronizationMonitor.waitUntilDataIsInTheServer(true);
+ tap(TestIdPack.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdPack.FIELD_CUSTOMER_MODAL, customerName);
+ tap(TestIdPack.BUTTON_CUSTOMER_MODAL_SEARCH);
+ SynchronizationMonitor.waitUntilRequestHaveFinished();
+ OBUtils.pause(5000);
+
+ /** loadBPartner **/
+ tap(TestIdPack.BUTTON_CUSTOMER_SEARCH_ROW1);
+
+ /** scanProduct **/
+ tap(TestIdPack.BUTTON_SCAN);
+ // Inputting 0000001688238 UPC/EAN code on the keypad
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_1);
+ tap(TestIdPack.BUTTON_KEYPAD_6);
+ tap(TestIdPack.BUTTON_KEYPAD_8);
+ tap(TestIdPack.BUTTON_KEYPAD_8);
+ tap(TestIdPack.BUTTON_KEYPAD_2);
+ tap(TestIdPack.BUTTON_KEYPAD_3);
+ tap(TestIdPack.BUTTON_KEYPAD_8);
+ tap(TestIdPack.BUTTON_KEYPAD_ENTER);
+ SynchronizationMonitor.waitUntilRequestHaveFinished();
+
+ /** scanProduct **/
+ tap(TestIdPack.BUTTON_SCAN);
+ // Inputting 0000001688191 UPC/EAN code on the keypad
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_1);
+ tap(TestIdPack.BUTTON_KEYPAD_6);
+ tap(TestIdPack.BUTTON_KEYPAD_8);
+ tap(TestIdPack.BUTTON_KEYPAD_8);
+ tap(TestIdPack.BUTTON_KEYPAD_1);
+ tap(TestIdPack.BUTTON_KEYPAD_9);
+ tap(TestIdPack.BUTTON_KEYPAD_1);
+ tap(TestIdPack.BUTTON_KEYPAD_ENTER);
+ SynchronizationMonitor.waitUntilRequestHaveFinished();
+
+ /** createTicket **/
+ OBUtils.pause(1000);
+ ticketId = getTicketId();
+ tap(TestIdPack.LABEL_TOTALTOPAY);
+ tap(TestIdPack.BUTTON_PAY_EXACT);
+
+ // Paying the ticket
+ tap(TestIdPack.BUTTON_PAY_DONE);
+
+ /** searchVerifyReturn **/
+ SynchronizationMonitor.waitUntiTheApplicationHasSynchronized();
+ SynchronizationMonitor.waitUntilDataIsInTheServer(true);
+ tap(TestIdPack.BUTTON_MENU);
+ tap(TestIdPack.BUTTON_MENU_VERIFIEDRETURN);
+ write(TestIdExtModules.FIELD_VERIFIED_RETURNS_FILTER_TXT, ticketId);
+ tap(TestIdPack.BUTTON_VERIFIEDRETURNS_SEARCH);
+
+ /** loadVerifyReturn **/
+ tap(TestIdPack.BUTTON_VERIFIEDRETURNS_ROW1);
+
+ /** verifyReturn **/
+ tap(TestIdPack.BUTTON_VERIFIEDRETURNS_LINES_CHECKALL);
+ tap(TestIdPack.BUTTON_POPUP_APPLY);
+
+ OBUtils.pause(4000);
+ // SynchronizationMonitor.waitUntiTheApplicationHasSynchronized();
+ tap(TestIdPack.LABEL_TOTALTOPAY);
+ tap(TestIdPack.BUTTON_PAY_EXACT);
+
+ tap(TestIdPack.BUTTON_PAY_DONE);
+
+ /** searchBPartner **/
+ tap(TestIdPack.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdPack.FIELD_CUSTOMER_MODAL, customerName);
+ tap(TestIdPack.BUTTON_CUSTOMER_MODAL_SEARCH);
+ SynchronizationMonitor.waitUntilRequestHaveFinished();
+
+ /** loadBPartner **/
+ tap(TestIdPack.BUTTON_CUSTOMER_SEARCH_ROW1);
+
+ /** searchProduct **/
+ tap(TestIdPack.BUTTON_SEARCH);
+ tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+
+ /** loadProduct **/
+ tap(TestIdPack.BUTTON_SEARCHPRODUCT_FIRSTROW);
+ SynchronizationMonitor.waitUntiTheApplicationHasSynchronized();
+ OBUtils.pause(1500);
+
+ /** searchProduct **/
+ tap(TestIdPack.BUTTON_SEARCH);
+ write(TestIdPack.FIELD_SEARCH_TEXT, "All mountain ski board Cham");
+ tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+
+ /** loadProduct **/
+ tap(TestIdPack.BUTTON_SEARCHPRODUCT_FIRSTROW);
+ SynchronizationMonitor.waitUntiTheApplicationHasSynchronized();
+ OBUtils.pause(1500);
+
+ /** createLayaway **/
+ tap(TestIdPack.BUTTON_MENU);
+ tap(TestIdPack.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+
+ tap(TestIdPack.LABEL_TOTALTOPAY);
+ SynchronizationMonitor.waitUntiTheApplicationHasSynchronized();
+ OBUtils.pause(4000);
+ // Storing the document number to later be searched in searchLayaway step
+ ticketId = getTicketId();
+ tap(TestIdPack.BUTTON_LAYAWAY);
+
+ /** searchLayaway **/
+ OBUtils.pause(4000);
+ SynchronizationMonitor.waitUntiTheApplicationHasSynchronized();
+ SynchronizationMonitor.waitUntilDataIsInTheServer(true);
+ tap(TestIdPack.BUTTON_MENU);
+ tap(TestIdPack.BUTTON_MENU_OPENRECEIPT);
+ // TODO: commented lines should replace the test functionality; currently commented due to not
+ // working on pi repo as of date 21 of june 2018
+ write(TestIdPack.FIELD_OPEN_RECEIPT_FILTER_TXT, ticketId);
+ tap(TestIdPack.BUTTON_OPEN_RECEIPT_SEARCH);
+ // tap(TestIdPack.BUTTON_OPEN_RECEIPT_ADVANCED_FILTER);
+ // // write(TestIdPack.FIELD_OPEN_RECEIPT_ADVANCED_FILTER_DOCUMENTNO, ticketId);
+ // TestIdPack.FIELD_OPEN_RECEIPT_ADVANCED_FILTER_ORDERTYPE_COMBO.enyoNode().executeExtension(
+ // ".setSelected(2)");
+ // tap(TestIdPack.BUTTON_ADVANCED_FILTERS_APPLY);
+ SynchronizationMonitor.waitUntiTheApplicationHasSynchronized();
+
+ /** loadLayaway **/
+ tap(TestIdPack.BUTTON_OPEN_RECEIPT_ROW1);
+ OBUtils.pause(5000);
+
+ /** payLayaway **/
+ tap(TestIdPack.LABEL_TOTALTOPAY);
+ OBUtils.pause(6000);
+ tap(TestIdPack.BUTTON_PAY_EXACT);
+ tap(TestIdPack.BUTTON_PAY_DONE);
+ SynchronizationMonitor.waitUntiTheApplicationHasSynchronized();
+ SynchronizationMonitor.waitUntilDataIsInTheServer(true);
+
+ /** incrementalRefresh **/
+ reload();
+
+ /** cashManagement **/
+ tap(TestIdPack.BUTTON_MENU);
+ tap(TestIdPack.BUTTON_MENU_CASHMANAGEMENT);
+
+ tap(TestIdPack.BUTTON_KEYPAD_5);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ // tap(TestIdPack.BUTTON_CASHMANAGEMENT_CASHDEPOSIT);
+ tap(TestIdPack.BUTTON_CASHMANAGEMENT_CASHDEPOSITBUTTON);
+ tap(TestIdPack.BUTTON_SELECTDEPOSIT_BACOFFICEVBS);
+ OBUtils.pause(2000);
+ tap(TestIdPack.BUTTON_CASHMANAGEMENT_DONE);
+ OBUtils.pause(5000);
+ // tap(TestIdPack.CONFIRMATION_POPUP);
+ // tap(TestIdPack.BUTTON_POPUP_CONFIRMATION_OK);
+ tap(TestIdPack.BUTTON_POPUP_OK);
+
+ /** cashUp **/
+ tap(TestIdPack.BUTTON_MENU);
+ tap(TestIdPack.BUTTON_MENU_CASHUP);
+ tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_010);
+ tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_050);
+ tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_1);
+ tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_2);
+
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ tap(TestIdPack.BUTTON_CASHUP_CARD_OK);
+ tap(TestIdPack.BUTTON_CASHUP_CASHUSA_OK);
+ tap(TestIdPack.BUTTON_CASHUP_VOUCHER_OK);
+
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ tap(TestIdPack.BUTTON_CASHUP_KEEPNOTHING);
+
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ tap(TestIdPack.BUTTON_CASHUP_KEEPNOTHING);
+
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ tap(TestIdPack.BUTTON_CASHUP_KEEPNOTHING);
+
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ tap(TestIdPack.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+ tap(TestIdPack.BUTTON_POPUP_OK);
+ }
+
+ private String getTicketId() {
+ String ticketId;
+ ticketId = get(TestIdPack.LABEL_DOCUMENTNUMBER);
+ if (ticketId.contains(" - ")) {
+ String[] ticketIdParts = ticketId.split(" - ");
+ if (ticketIdParts.length > 2) {
+ ticketId = ticketIdParts[2];
+ } else {
+ ticketId = ticketIdParts[1];
+ }
+ }
+ return ticketId;
+ }
+}
jMeterRecordingInfrastructure_patch1.diff [^] (43,495 bytes) 2018-10-26 10:16 [Show Content] [Hide Content]diff --git a/src-test/org/openbravo/test/mobile/core/selenium/SeleniumHelper.java b/src-test/org/openbravo/test/mobile/core/selenium/SeleniumHelper.java
--- a/src-test/org/openbravo/test/mobile/core/selenium/SeleniumHelper.java
+++ b/src-test/org/openbravo/test/mobile/core/selenium/SeleniumHelper.java
@@ -44,6 +44,7 @@
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.OutputType;
+import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.chrome.ChromeOptions;
@@ -69,6 +70,7 @@
/** The Remote Web Driver singleton instance. This is used to execute actions on web pages. */
private static RemoteWebDriver INSTANCE = null;
private static boolean isLogCapabilities = false;
+ private static boolean hasProxyCapability = false;
/**
* Start the selenium instance.
@@ -128,6 +130,12 @@
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
+ if (hasProxyCapability()) {
+ final String PROXY = "localhost:8080";
+ final Proxy proxy = new Proxy().setHttpProxy(PROXY).setSslProxy(PROXY).setSocksProxy(PROXY);
+ capabilities.setCapability(CapabilityType.PROXY, proxy);
+ }
+
// logging
// activating this logs can lead to memory leaks
// https://code.google.com/p/selenium/wiki/Logging
@@ -187,6 +195,14 @@
return INSTANCE != null;
}
+ public static boolean hasProxyCapability() {
+ return hasProxyCapability;
+ }
+
+ public static void setProxyCapability(boolean activateProxy) {
+ hasProxyCapability = activateProxy;
+ }
+
public static void loadURI(final String uri) {
INSTANCE.get(uri);
}
diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java
--- a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java
@@ -250,6 +250,8 @@
"theButton_btnPrev", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_SESSIONS_OPENTILL_DONE = new TestIdConstructor(
"theButton_btnNext", EnyoKind.BUTTON); //
+ public static TestIdConstructor BUTTON_SESSIONS_OPENTILL_CANCEL = new TestIdConstructor(
+ "theButton_btnCancel", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_KEYPAD_SLASH = new TestIdConstructor("toolbarBtn1_button",
EnyoKind.BUTTON); //
public static TestIdConstructor LABEL_SESSIONS_OPENTILL_TOTAL = new TestIdConstructor(
diff --git a/src-test/org/openbravo/test/mobile/retail/mobilecore/selenium/TestIdConstructor.java b/src-test/org/openbravo/test/mobile/retail/mobilecore/selenium/TestIdConstructor.java
--- a/src-test/org/openbravo/test/mobile/retail/mobilecore/selenium/TestIdConstructor.java
+++ b/src-test/org/openbravo/test/mobile/retail/mobilecore/selenium/TestIdConstructor.java
@@ -11,6 +11,11 @@
private String rowValue = null;
private String enyoName = null;
private String verifyString = null;
+ private String jmeterTag = null;
+ private String chainReplacedJmeterTag = null;
+ private TestIdConstructor chainedToTestId = null;
+ private String chainedToJmeterTag = null;
+ private boolean hasWait = false;
@Override
public String toString() {
@@ -27,9 +32,27 @@
return null;
}
+ private void TestIdObjectConstructor(final String _testId, final EnyoKind _enyoKind,
+ final TestIdConstructor _testIdToVerify, final String _rowValue, final String _enyoName,
+ final String _verifyString, final String _jmeterTag, final String _chainReplacedJmeterTag,
+ final TestIdConstructor _chainedToTestId, final String _chainedToJmeterTag,
+ final boolean _hasWait) {
+ this.testId = _testId;
+ this.enyoKind = _enyoKind;
+ this.testIdToVerify = _testIdToVerify;
+ this.rowValue = _rowValue;
+ this.enyoName = _enyoName;
+ this.verifyString = _verifyString;
+ this.jmeterTag = _jmeterTag;
+ this.chainReplacedJmeterTag = _chainReplacedJmeterTag;
+ this.chainedToTestId = _chainedToTestId;
+ this.chainedToJmeterTag = _chainedToJmeterTag;
+ this.hasWait = _hasWait;
+ }
+
public TestIdConstructor(final String testId) {
- this.testId = testId;
- enyoKind = EnyoKind.UNKOWN;
+ TestIdObjectConstructor(testId, EnyoKind.UNKOWN, null, null, null, null, null, null, null,
+ null, false);
}
public TestIdConstructor(final String idtestOrRowToFind, final EnyoKind enyoKind) {
@@ -40,19 +63,17 @@
if (enyoKind == EnyoKind.CATEGORY || enyoKind == EnyoKind.SEARCHCATEGORY
|| enyoKind == EnyoKind.PRODUCT || enyoKind == EnyoKind.CUSTOMER
|| enyoKind == EnyoKind.SEARCHPRODUCT) {
- rowValue = idtestOrRowToFind;
- enyoName = "identifier";
- verifyString = idtestOrRowToFind;
+ TestIdObjectConstructor(null, enyoKind, null, idtestOrRowToFind, "identifier",
+ idtestOrRowToFind, null, null, null, null, false);
} else {
- testId = idtestOrRowToFind;
+ TestIdObjectConstructor(idtestOrRowToFind, enyoKind, null, null, null, null, null, null,
+ null, null, false);
}
- this.enyoKind = enyoKind;
}
public TestIdConstructor(final String rowName, final String enyoName, final EnyoKind enyoKind) {
- rowValue = rowName;
- this.enyoName = enyoName;
- this.enyoKind = enyoKind;
+ TestIdObjectConstructor(null, enyoKind, null, rowName, enyoName, null, null, null, null, null,
+ false);
}
public TestIdConstructor(final String idtest, final EnyoKind enyoKind, final String enyoName) {
@@ -60,19 +81,159 @@
throw new IllegalArgumentException(String.format(
"%s: This method can only be accesed by SCROLLABLETABLE objects", name()));
}
- testId = idtest;
- this.enyoKind = enyoKind;
- this.enyoName = enyoName;
+ TestIdObjectConstructor(idtest, enyoKind, null, null, enyoName, null, null, null, null, null,
+ false);
}
public TestIdConstructor(final String idtest, final EnyoKind enyoKind,
final TestIdConstructor testIdToVerify, final String verifyString) {
- testId = idtest;
- this.enyoKind = enyoKind;
- this.testIdToVerify = testIdToVerify;
- this.verifyString = verifyString;
+ TestIdObjectConstructor(idtest, enyoKind, testIdToVerify, null, null, verifyString, null, null,
+ null, null, false);
+ }
+
+ /**
+ * TestIdConstructors with added JMeter controller tag parameter for the recording of the tests
+ */
+
+ public TestIdConstructor(final String testId, final boolean hasWait) {
+ TestIdObjectConstructor(testId, EnyoKind.UNKOWN, null, null, null, null, null, null, null,
+ null, hasWait);
+ }
+
+ public TestIdConstructor(final String testId, final String jmeterTag, final boolean hasWait) {
+ TestIdObjectConstructor(testId, EnyoKind.UNKOWN, null, null, null, null, jmeterTag, null, null,
+ null, hasWait);
+ }
+
+ public TestIdConstructor(final EnyoKind enyoKind, final String idtestOrRowToFind,
+ final String jmeterTag, final boolean hasWait) {
+ if (enyoKind == EnyoKind.SCROLLABLETABLE) {
+ throw new IllegalArgumentException(
+ "This method is not intended to register pure scrollableTable objects. Specify the name of the enyo object that contains the key value");
+ }
+ if (enyoKind == EnyoKind.CATEGORY || enyoKind == EnyoKind.SEARCHCATEGORY
+ || enyoKind == EnyoKind.PRODUCT || enyoKind == EnyoKind.CUSTOMER
+ || enyoKind == EnyoKind.SEARCHPRODUCT) {
+ TestIdObjectConstructor(null, enyoKind, null, idtestOrRowToFind, "identifier",
+ idtestOrRowToFind, jmeterTag, null, null, null, hasWait);
+ } else {
+ TestIdObjectConstructor(idtestOrRowToFind, enyoKind, null, null, null, null, jmeterTag, null,
+ null, null, hasWait);
+ }
+ }
+
+ public TestIdConstructor(final String rowName, final String enyoName, final EnyoKind enyoKind,
+ final String jmeterTag, final boolean hasWait) {
+ TestIdObjectConstructor(null, enyoKind, null, rowName, enyoName, null, jmeterTag, null, null,
+ null, hasWait);
+ }
+
+ public TestIdConstructor(final String idtestOrRowToFind, final EnyoKind enyoKind,
+ final boolean hasWait) {
+ if (enyoKind == EnyoKind.SCROLLABLETABLE) {
+ throw new IllegalArgumentException(
+ "This method is not intended to register pure scrollableTable objects. Specify the name of the enyo object that contains the key value");
+ }
+ if (enyoKind == EnyoKind.CATEGORY || enyoKind == EnyoKind.SEARCHCATEGORY
+ || enyoKind == EnyoKind.PRODUCT || enyoKind == EnyoKind.CUSTOMER
+ || enyoKind == EnyoKind.SEARCHPRODUCT) {
+ TestIdObjectConstructor(null, enyoKind, null, idtestOrRowToFind, "identifier",
+ idtestOrRowToFind, null, null, null, null, hasWait);
+ } else {
+ TestIdObjectConstructor(idtestOrRowToFind, enyoKind, null, null, null, null, null, null,
+ null, null, hasWait);
+ }
+ }
+
+ public TestIdConstructor(final String idtest, final EnyoKind enyoKind, final String enyoName,
+ final String jmeterTag, final boolean hasWait) {
+ if (enyoKind != EnyoKind.SCROLLABLETABLE) {
+ throw new IllegalArgumentException(String.format(
+ "%s: This method can only be accesed by SCROLLABLETABLE objects", name()));
+ }
+ TestIdObjectConstructor(idtest, enyoKind, null, null, enyoName, null, jmeterTag, null, null,
+ null, hasWait);
}
+ public TestIdConstructor(final String idtest, final EnyoKind enyoKind,
+ final TestIdConstructor testIdToVerify, final String verifyString, final String jmeterTag,
+ final boolean hasWait) {
+ TestIdObjectConstructor(idtest, enyoKind, testIdToVerify, null, null, verifyString, jmeterTag,
+ null, null, null, hasWait);
+ }
+
+ public TestIdConstructor(final String testId, final String jmeterTag,
+ final TestIdConstructor chainedToTestId, final String chainedToJmeterTag,
+ final boolean hasWait) {
+ TestIdObjectConstructor(testId, EnyoKind.UNKOWN, null, null, null, null, jmeterTag, null,
+ chainedToTestId,
+ chainedToJmeterTag, hasWait);
+ }
+
+ public TestIdConstructor(final EnyoKind enyoKind, final String idtestOrRowToFind,
+ final String jmeterTag, final TestIdConstructor chainedToTestId,
+ final String chainedToJmeterTag, final boolean hasWait) {
+ if (enyoKind == EnyoKind.SCROLLABLETABLE) {
+ throw new IllegalArgumentException(
+ "This method is not intended to register pure scrollableTable objects. Specify the name of the enyo object that contains the key value");
+ }
+ if (enyoKind == EnyoKind.CATEGORY || enyoKind == EnyoKind.SEARCHCATEGORY
+ || enyoKind == EnyoKind.PRODUCT || enyoKind == EnyoKind.CUSTOMER
+ || enyoKind == EnyoKind.SEARCHPRODUCT) {
+ TestIdObjectConstructor(null, enyoKind, null, idtestOrRowToFind, "identifier",
+ idtestOrRowToFind, jmeterTag, null, chainedToTestId, chainedToJmeterTag, hasWait);
+ } else {
+ TestIdObjectConstructor(idtestOrRowToFind, enyoKind, null, null, null, null, jmeterTag, null,
+ chainedToTestId, chainedToJmeterTag, hasWait);
+ }
+ }
+
+ public TestIdConstructor(final String rowName, final String enyoName, final EnyoKind enyoKind,
+ final String jmeterTag, final TestIdConstructor chainedToTestId,
+ final String chainedToJmeterTag, final boolean hasWait) {
+ TestIdObjectConstructor(null, enyoKind, null, rowName, enyoName, null, jmeterTag, null,
+ chainedToTestId, chainedToJmeterTag, hasWait);
+ }
+
+ public TestIdConstructor(final String idtestOrRowToFind, final EnyoKind enyoKind,
+ final TestIdConstructor chainedToTestId, final String chainedToJmeterTag,
+ final boolean hasWait) {
+ if (enyoKind == EnyoKind.SCROLLABLETABLE) {
+ throw new IllegalArgumentException(
+ "This method is not intended to register pure scrollableTable objects. Specify the name of the enyo object that contains the key value");
+ }
+ if (enyoKind == EnyoKind.CATEGORY || enyoKind == EnyoKind.SEARCHCATEGORY
+ || enyoKind == EnyoKind.PRODUCT || enyoKind == EnyoKind.CUSTOMER
+ || enyoKind == EnyoKind.SEARCHPRODUCT) {
+ TestIdObjectConstructor(null, enyoKind, null, idtestOrRowToFind, "identifier",
+ idtestOrRowToFind, null, null, chainedToTestId, chainedToJmeterTag, hasWait);
+ } else {
+ TestIdObjectConstructor(idtestOrRowToFind, enyoKind, null, null, null, null, null, null,
+ chainedToTestId, chainedToJmeterTag, hasWait);
+ }
+ }
+
+ public TestIdConstructor(final String idtest, final EnyoKind enyoKind, final String enyoName,
+ final String jmeterTag, final TestIdConstructor chainedToTestId,
+ final String chainedToJmeterTag, final boolean hasWait) {
+ if (enyoKind != EnyoKind.SCROLLABLETABLE) {
+ throw new IllegalArgumentException(String.format(
+ "%s: This method can only be accesed by SCROLLABLETABLE objects", name()));
+ }
+ TestIdObjectConstructor(idtest, enyoKind, null, null, enyoName, null, jmeterTag, null,
+ chainedToTestId, chainedToJmeterTag, hasWait);
+ }
+
+ public TestIdConstructor(final String idtest, final EnyoKind enyoKind,
+ final TestIdConstructor testIdToVerify, final String verifyString, final String jmeterTag,
+ final TestIdConstructor chainedToTestId, final String chainedToJmeterTag,
+ final boolean hasWait) {
+ TestIdObjectConstructor(idtest, enyoKind, testIdToVerify, null, null, verifyString, jmeterTag,
+ null, chainedToTestId, chainedToJmeterTag, hasWait);
+ }
+
+ //
+
public String getTestId() {
if (testId == null) {
throw new IllegalArgumentException(name()
@@ -105,6 +266,50 @@
return enyoName;
}
+ /**
+ * Getters and setters for TestIds to be used with JMeter
+ */
+ public String getJMeterTag() {
+ return this.jmeterTag;
+ }
+
+ public boolean hasWait() {
+ return this.hasWait;
+ }
+
+ private boolean hasChainedToTestId() {
+ return this.chainedToTestId != null;
+ }
+
+ private boolean hasChainReplacedJMeterTag() {
+ return this.chainReplacedJmeterTag != null;
+ }
+
+ private TestIdConstructor setChainReplacedJMeterTag(String chainedToJMeterTag) {
+ this.chainReplacedJmeterTag = chainedToJMeterTag;
+ return this;
+ }
+
+ /**
+ * Checks whether this is chained to or chained by another TestId and manages the replacement
+ * jmeterTag as needed before its use.
+ *
+ * @return The current jmeterTag in use
+ */
+ public String evaluate() {
+ String currentJMeterTag = getJMeterTag();
+ if (hasChainedToTestId()) {
+ chainedToTestId.setChainReplacedJMeterTag(this.chainedToJmeterTag);
+ }
+ if (hasChainReplacedJMeterTag()) {
+ currentJMeterTag = this.chainReplacedJmeterTag;
+ this.chainReplacedJmeterTag = null;
+ }
+ return currentJMeterTag != null ? currentJMeterTag : "";
+ }
+
+ //
+
public boolean isCategoryOrProduct() {
if (enyoKind == EnyoKind.CATEGORY || enyoKind == EnyoKind.SEARCHCATEGORY
|| enyoKind == EnyoKind.PRODUCT) {
diff --git a/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java b/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java
@@ -97,12 +97,12 @@
"btnTotalToPay_totalPrinter"); //
public static TestIdConstructor LABEL_TOTALTOPAY = new TestIdConstructor(
- "theButton_btnTotalToPay"); //
+ "theButton_btnTotalToPay", "createTicket", false); //
public static TestIdConstructor BUTTON_BROWSE = new TestIdConstructor(
"theButton_toolbarBtnCatalog", EnyoKind.BUTTON, TestIdPack.LABEL_CATEGORYTABLE_TITLE,
"Categories"); //
- public static TestIdConstructor BUTTON_SCAN = new TestIdConstructor("theButton_toolbarBtnScan",
- EnyoKind.BUTTON); //
+ public static TestIdConstructor BUTTON_SCAN = new TestIdConstructor(EnyoKind.BUTTON,
+ "theButton_toolbarBtnScan", "scanProduct", false); //
public static TestIdConstructor BUTTON_SCAN_UNDO = new TestIdConstructor(
"scanTabContent_undobutton", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_EDIT = new TestIdConstructor("theButton_toolbarBtnEdit",
@@ -151,7 +151,8 @@
public static TestIdConstructor BUTTON_MENU_INVOICETHISRECEIPT = new TestIdConstructor(
"menuScroller_menuInvoice", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_MENU_LAYAWAYTHISRECEIPT = new TestIdConstructor(
- "menuScroller_menuLayaway", EnyoKind.BUTTON); //
+ EnyoKind.BUTTON, "menuScroller_menuLayaway", "createLayaway", TestIdPack.LABEL_TOTALTOPAY,
+ "", false); //
public static TestIdConstructor BUTTON_MENU_REJECTQUOTATIONS = new TestIdConstructor(
"menuScroller_menuRejectQuotation", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_MENU_RECEIPTDISCOUNTS = new TestIdConstructor(
@@ -165,7 +166,7 @@
public static TestIdConstructor BUTTON_MENU_RECEIPTTHISLAYAWAY = new TestIdConstructor(
"menuScroller_menuReceiptLayaway", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_MENU_CASHMANAGEMENT = new TestIdConstructor(
- "OB.UI.MenuWindowItem.OBPOS_LblCashManagement", EnyoKind.BUTTON); //
+ EnyoKind.BUTTON, "OB.UI.MenuWindowItem.OBPOS_LblCashManagement", "cashManagement", false); //
public static TestIdConstructor BUTTON_MENU_PAYOPENTICKETS = new TestIdConstructor(
"menuScroller_menuMultiOrders", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_MENU_SELECT_PRINTER = new TestIdConstructor(
@@ -186,8 +187,8 @@
"menuScroller_OB.UI.MenuUserInfo", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_MENU_OPENDRAWER = new TestIdConstructor(
"menuScroller_menuOpenDrawer", EnyoKind.BUTTON); //
- public static TestIdConstructor BUTTON_MENU_OPENRECEIPT = new TestIdConstructor(
- "menuScroller_menuReceiptSelector", EnyoKind.BUTTON); //
+ public static TestIdConstructor BUTTON_MENU_OPENRECEIPT = new TestIdConstructor(EnyoKind.BUTTON,
+ "menuScroller_menuReceiptSelector", "searchLayaway", false); //
// Modal User Dialog
public static TestIdConstructor BUTTON_USER_PROFILE = new TestIdConstructor(
@@ -372,7 +373,8 @@
public static TestIdConstructor BUTTON_PAYMENTMETHOD_POPUP_CLOSE = new TestIdConstructor(
"modalPaymentsSelect_closebutton"); //
public static TestIdConstructor BUTTON_LAYAWAY = new TestIdConstructor(
- "paymentTabContent_layawayaction", EnyoKind.BUTTON); //
+ "paymentTabContent_layawayaction", EnyoKind.BUTTON, TestIdPack.LABEL_TOTALTOPAY,
+ "payLayaway", true); //
public static TestIdConstructor BUTTON_RECEIPT_ROW1 = new TestIdConstructor("listOrderLines_row1"); //
public static TestIdConstructor LABEL_RECEIPT_ROW1 = new TestIdConstructor("listOrderLines_row1"); //
public static TestIdConstructor LABEL_RECEIPT_ROW1_SERIAL_NUMBER_DISCOUNT = new TestIdConstructor(
@@ -804,11 +806,11 @@
public static TestIdConstructor BUTTON_CUSTOMER_MODAL_CLEAN = new TestIdConstructor(
"stBPAssignToReceipt_smallButton", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_CUSTOMER_MODAL_SEARCH = new TestIdConstructor(
- "stBPAssignToReceipt_entitySearchBtn", EnyoKind.BUTTON); //
+ EnyoKind.BUTTON, "stBPAssignToReceipt_entitySearchBtn", "searchBPartner", false); //
public static TestIdConstructor BUTTON_CUSTOMER_NEW = new TestIdConstructor(
"stBPAssignToReceipt_newAction", EnyoKind.BUTTON); //
- public static TestIdConstructor BUTTON_CUSTOMER_SAVE = new TestIdConstructor(
- "bodyheader_newcustomersave", EnyoKind.BUTTON); //
+ public static TestIdConstructor BUTTON_CUSTOMER_SAVE = new TestIdConstructor(EnyoKind.BUTTON,
+ "bodyheader_newcustomersave", "createBPartner", false); //
public static TestIdConstructor FIELD_CUSTOMER_NAME = new TestIdConstructor(
"newAttribute_firstName"); //
public static TestIdConstructor FIELD_CUSTOMER_LASTNAME = new TestIdConstructor(
@@ -852,7 +854,7 @@
public static TestIdConstructor BUTTON_CUSTOMER_DETAILS_CLOSE = new TestIdConstructor(
"customerView_closebutton", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_CUSTOMER_EDIT_CLOSE = new TestIdConstructor(
- "customerCreateAndEdit_closebutton", EnyoKind.BUTTON); //
+ "customerCreateAndEdit_closebutton", EnyoKind.BUTTON, true); //
public static TestIdConstructor BUTTON_CUSTOMERADDRESS_SELECTOR_CLOSE = new TestIdConstructor(
"modalcustomeraddress_closebutton", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_CUSTOMERSHIPPINGADDRESS_SELECTOR_CLOSE = new TestIdConstructor(
@@ -953,8 +955,8 @@
"customerPriceList_customerCombo", EnyoKind.BUTTON); //
// Search Characteristic
- public static TestIdConstructor BUTTON_SEARCH = new TestIdConstructor(
- "theButton_toolbarBtnSearchCharacteristic", EnyoKind.BUTTON); //
+ public static TestIdConstructor BUTTON_SEARCH = new TestIdConstructor(EnyoKind.BUTTON,
+ "theButton_toolbarBtnSearchCharacteristic", "searchProduct", false); //
public static TestIdConstructor FIELD_SEARCH_TEXT = new TestIdConstructor(
"searchProductCharacteristicHeader_productFilterText"); //
public static TestIdConstructor FIELD_SEARCH_CATEGORY = new TestIdConstructor(
@@ -1256,7 +1258,7 @@
// Buttons
public static TestIdConstructor MENU_CONTAINER = new TestIdConstructor("mainMenu_menuHolder"); //
public static TestIdConstructor BUTTON_MENU_CASHUP = new TestIdConstructor(
- "OB.UI.MenuWindowItem.OBPOS_LblCloseCash"); //
+ "OB.UI.MenuWindowItem.OBPOS_LblCloseCash", "cashUp", false); //
public static TestIdConstructor BUTTON_MENU_CASHUPPARTIAL = new TestIdConstructor(
"OB.UI.MenuWindowItem.OBPOS_LblCloseCashPartial"); //
public static TestIdConstructor BUTTON_LOCKSCREEN = new TestIdConstructor(
@@ -1430,7 +1432,7 @@
public static TestIdConstructor BUTTON_PAY_EXACT = new TestIdConstructor(
"paymentTabContent_exactbutton", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_PAY_DONE = new TestIdConstructor(
- "paymentTabContent_donebutton", EnyoKind.BUTTON); //
+ "paymentTabContent_donebutton", EnyoKind.BUTTON, true); //
public static TestIdConstructor BUTTON_PAY_USECREDIT = new TestIdConstructor(
"paymentTabContent_creditsalesaction", EnyoKind.BUTTON); //
public static TestIdConstructor LABEL_PAYMENT_LIMITEDAMOUNT_EXCEEDED = new TestIdConstructor(
@@ -1604,7 +1606,8 @@
public static TestIdConstructor FIELD_VERIFIED_RETURNS_FILTER_TXT = new TestIdConstructor(
"verifiedReturnsReceiptsListItemPrinter_entityFilterText"); //
public static TestIdConstructor BUTTON_VERIFIEDRETURNS_SEARCH = new TestIdConstructor(
- "verifiedReturnsReceiptsListItemPrinter_entitySearchBtn", EnyoKind.BUTTON); //
+ EnyoKind.BUTTON, "verifiedReturnsReceiptsListItemPrinter_entitySearchBtn",
+ "searchVerifyReturn", false); //
public static TestIdConstructor LABEL_VERIFIED_RETURNS_SEARCH_RESULT_ROW1_DOCUMENTNO = new TestIdConstructor(
"verifiedReturnsReceiptsListItemPrinter_row1_documentNo"); //
public static TestIdConstructor LABEL_VERIFIED_RETURNS_SEARCH_RESULT_ROW1_CUSTOMER = new TestIdConstructor(
@@ -1614,7 +1617,8 @@
public static TestIdConstructor LABEL_VERIFIED_RETURNS_SEARCH_RESULT_ROW2_CUSTOMER = new TestIdConstructor(
"verifiedReturnsReceiptsListItemPrinter_row2_customer"); //
public static TestIdConstructor BUTTON_VERIFIEDRETURNS_ROW1 = new TestIdConstructor(
- "verifiedReturnsReceiptsListItemPrinter_row1_receiptSelectorRenderLine", EnyoKind.BUTTON); //
+ EnyoKind.BUTTON, "verifiedReturnsReceiptsListItemPrinter_row1_receiptSelectorRenderLine",
+ "loadVerifyReturn", false); //
public static TestIdConstructor BUTTON_VERIFIEDRETURNS_ROW2 = new TestIdConstructor(
"verifiedReturnsReceiptsListItemPrinter_row2_receiptSelectorRenderLine", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_VERIFIEDRETURNS_LINES_CHECKALL = new TestIdConstructor(
@@ -1848,7 +1852,7 @@
// Popups
public static TestIdConstructor CONFIRMATION_POPUP = new TestIdConstructor(
- "confirmationContainer_dynamicConfirmationPopup"); //
+ "confirmationContainer_dynamicConfirmationPopup", true); //
public static TestIdConstructor ERROR_POPUP = new TestIdConstructor("terminal_alertQueue"); //
public static TestIdConstructor BUTTON_POPUP_OK = new TestIdConstructor(
"confirmationPopup_btnOK", EnyoKind.BUTTON); //
@@ -2524,7 +2528,7 @@
public static TestIdConstructor LABEL_CASHUP_POSTPRINTANDCLOSE = new TestIdConstructor(
"theButton_btnNext"); //
public static TestIdConstructor BUTTON_CASHUP_POSTPRINTANDCLOSE = new TestIdConstructor(
- "theButton_btnNext", EnyoKind.BUTTON); //
+ "theButton_btnNext", EnyoKind.BUTTON, TestIdPack.BUTTON_POPUP_OK, "logOut", true); //
// Business partner modal
public static TestIdConstructor FIELD_CUSTOMER_MODAL = new TestIdConstructor(
@@ -2540,7 +2544,7 @@
public static TestIdConstructor LABEL_CUSTOMER_SEARCH_IDENTIFIER = new TestIdConstructor(
"stBPAssignToReceipt_row1_identifier"); //
public static TestIdConstructor BUTTON_CUSTOMER_SEARCH_ROW1 = new TestIdConstructor(
- "stBPAssignToReceipt_row1"); //
+ "stBPAssignToReceipt_row1", "loadBPartner", false); //
public static TestIdConstructor LABEL_CUSTOMER_LIST_ROW1 = new TestIdConstructor(
"stBPAssignToReceipt_row1_listBpsSelectorLine"); //
public static TestIdConstructor LABEL_CUSTOMER_SEARCH_ROW1 = new TestIdConstructor(
@@ -2621,7 +2625,7 @@
EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_SEARCHPRODUCT_FIRSTROW = new TestIdConstructor(
- "products_row1", EnyoKind.BUTTON); //
+ EnyoKind.BUTTON, "products_row1", "loadProduct", false); //
public static TestIdConstructor INPUT_POINTOFSALE = new TestIdConstructor("keyboard_editbox"); //
// Returns Approval
@@ -2986,8 +2990,8 @@
"openreceiptslistitemprinter_entityFilterText"); //
public static TestIdConstructor BUTTON_OPEN_RECEIPT_SEARCH = new TestIdConstructor(
"openreceiptslistitemprinter_entitySearchBtn", EnyoKind.BUTTON);
- public static TestIdConstructor BUTTON_OPEN_RECEIPT_ROW1 = new TestIdConstructor(
- "openreceiptslistitemprinter_row1_receiptSelectorRenderLine", EnyoKind.BUTTON);
+ public static TestIdConstructor BUTTON_OPEN_RECEIPT_ROW1 = new TestIdConstructor(EnyoKind.BUTTON,
+ "openreceiptslistitemprinter_row1_receiptSelectorRenderLine", "loadLayaway", false);
public static TestIdConstructor FIELD_OPEN_RECEIPT_FILTER_COMBO = new TestIdConstructor(
"openreceiptslistitemprinter_entityFilterColumn"); //
public static TestIdConstructor FIELD_OPEN_RECEIPT_FILTER_ORDERTYPE_COMBO = new TestIdConstructor(
diff --git a/src-test/org/openbravo/test/mobile/retail/pack/selenium/terminals/WebPOSJMeterTerminalHelper.java b/src-test/org/openbravo/test/mobile/retail/pack/selenium/terminals/WebPOSJMeterTerminalHelper.java
new file mode 100644
--- /dev/null
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/terminals/WebPOSJMeterTerminalHelper.java
@@ -0,0 +1,402 @@
+/*
+ *************************************************************************
+ * 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 igarcia
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.terminals;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+import org.junit.rules.Timeout;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.core.utils.ConfigurationProperties;
+import org.openbravo.test.mobile.core.utils.OBConstants;
+import org.openbravo.test.mobile.core.utils.OBUtils;
+import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
+import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.EnyoKind;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.MobileCoreAPI;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.SynchronizationMonitor;
+import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
+import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdCore;
+import org.openbravo.test.mobile.retail.mobilecore.utils.ApplicationWindow;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+
+/**
+ * Encapsulates the logic for the terminal of the base WebPOS for JMeter test script recording
+ * (retail pack)
+ *
+ */
+public abstract class WebPOSJMeterTerminalHelper extends WebPOSExtModulesTerminalHelper {
+ private static final String DEFAULT_JMETER_TERMINAL = System.getProperty("terminalName") == null ? "VBS-1"
+ : System.getProperty("terminalName");
+ private static final String DEFAULT_JMETER_USER = "vallblanca";
+ private static final String DEFAULT_JMETER_PASSWORD = "openbravo";
+ private static final String DEFAULT_PATH = "org.openbravo.retail.posterminal";
+
+ // 30 minutes timeout specific for the test
+ @Rule
+ public final TestRule jmeterTestTimeout = new Timeout(30 * 60 * 1000);
+
+ // Auxiliary variables for method
+ private final String baseUrl = ConfigurationProperties.INSTANCE.getOpenbravoBaseURL();
+ private final String context = ConfigurationProperties.INSTANCE.getOpenbravoContext();
+ private final String mod = "/web/" + DEFAULT_PATH + "/";
+ private final String jMeterControllerTag = "?terminal=" + super.getTerminal()
+ + "&controller=##controller####stateArg##";
+ private final String jMeterCTState = "&state=##state##";
+ private final String fullUrl = baseUrl + context + mod + jMeterControllerTag;
+ private final String httpGetVarUrlSend = "var xmlHttp = new XMLHttpRequest(); "
+ + "xmlHttp.open(\"GET\", \"##completeUrl##\", false); " + "xmlHttp.send();";
+ private final Map<Object, Handler> singleTIdMap = new HashMap<Object, Handler>();
+ // TODO: set this field to false back again
+ private boolean isLoggedInForJMeterRecording = false; // Flag that indicates whether HTTP marks
+ // are to be introduced, set to false at the
+ // start due to the need of loading the
+ // cache prior to the actual test
+ private boolean openTillShowed = false; // Flag that indicates whether the Open Till window has
+ private boolean checkIfInPOSWindow = false; // Flag that indicates whether we need to check if
+ // reached to point of sale window after opening the
+ // tills
+ // shown upon initial login to load the cache
+ private static boolean isProxyActive = false; // Flag that enables the proxy with JMeter recorder
+ // to be able to record the tests. This is also used
+ // to toggle the waits needed for when recording
+ private static boolean isOpenTill = true; // Flag that indicates whether the Sessions module is
+ // installed, and thus will serve to take into account
+ // the "Open Till" step in the test
+
+ private class Handler {
+ public void handle() {
+ }
+
+ public void setControllerName(final String s) {
+ setHttpRequestControllerMark(s);
+ }
+ }
+
+ public WebPOSJMeterTerminalHelper() {
+ super(DEFAULT_JMETER_TERMINAL, DEFAULT_JMETER_USER, DEFAULT_JMETER_PASSWORD, isOpenTill);
+ OBConstants.WAIT_DEFAULT_RETRIES = 1500;
+ initializeHttpMarkerMap();
+ }
+
+ public WebPOSJMeterTerminalHelper(final String terminal) {
+ super(terminal, DEFAULT_JMETER_USER, DEFAULT_JMETER_PASSWORD);
+ initializeHttpMarkerMap();
+ }
+
+ public WebPOSJMeterTerminalHelper(final String terminal, final String username,
+ final String password) {
+ super(terminal, username, password);
+ initializeHttpMarkerMap();
+ }
+
+ /**
+ * Sets up the ability to send the JMeter tag as an HTTP requests for the TestIds or enyoKinds
+ * predefined in the initializeHttpMarkerMap method
+ *
+ * @param tIdOrEnyoKind
+ * @param cName
+ */
+ private void setSingleTestIdWithRequestMapElement(final Object tIdOrEnyoKind, final String cName) {
+ singleTIdMap.put(tIdOrEnyoKind, new Handler() {
+ @Override
+ public void handle() {
+ setControllerName(cName);
+ }
+ });
+ }
+
+ /**
+ * Initializes the HTTP Marker map with names of the JMeter test controllers that are to be sent
+ * depending on which Test Id(s) are clicked
+ *
+ */
+ private void initializeHttpMarkerMap() {
+ // Adding EnyoKinds to verify groups of TestIdConstructors
+ // For example, all TestIdConstructor instances with the shape of
+ // TestIdPack.BUTTON_SEARCHPRODUCT_* have the EnyoKind instance EnyoKind.SEARCHPRODUCT. Can
+ // obtain the EnyoKind type via .enyoNode().getEnyoKind() method combination
+ setSingleTestIdWithRequestMapElement(EnyoKind.SEARCHPRODUCT, "loadProduct");
+ }
+
+ /**
+ * Sends the actual HTTP request with the JMeter tag via the JMeter Proxy. This tag is used to
+ * define the JMeter controller names
+ *
+ * @param controller
+ */
+ public void setHttpRequestControllerMark(final String controller) {
+ setHttpRequestControllerMark(controller, "");
+ }
+
+ /**
+ * Sends an HTTP GET request via the WebDriver proxy to JMeter, which are used as a marker to
+ * separate requests. These marker requests are used to classify the requests in the controllers
+ * of the JMeter test script, once all requests have been recorded
+ *
+ * @param controller
+ * Name of the controller in which to split the requests
+ * @param state
+ * Either "start" or "end" for the delimiting (optional)
+ */
+ public void setHttpRequestControllerMark(final String controller, final String state) {
+ final String completeUrl;
+ if (controller == null) {
+ return;
+ }
+ if (controller.isEmpty()) {
+ return;
+ }
+ if (state == "") {
+ completeUrl = getCompleteUrlForMark(controller);
+ } else {
+ completeUrl = getCompleteUrlForMark(controller, state);
+ }
+ SeleniumHelper.executeScript(httpGetVarUrlSend.replace("##completeUrl##", completeUrl));
+ }
+
+ /**
+ * Gets the complete url for the marker requests
+ *
+ * @param controller
+ * Name of the controller in which to split the requests
+ * @param state
+ * Either "start" or "end" for the delimiting
+ *
+ */
+ public String getCompleteUrlForMark(final String controller, final String state) {
+ final String stateArg = jMeterCTState.replace("##state##", state);
+ return fullUrl.replace("##controller##", controller).replace("##stateArg##", stateArg);
+ }
+
+ public String getCompleteUrlForMark(final String controller) {
+ return fullUrl.replace("##controller##", controller).replace("##stateArg##", "");
+ }
+
+ @Override
+ protected void logIn() {
+ SeleniumHelper.setProxyCapability(isProxyActive);
+ super.logIn(); // Full refresh login
+ logOut();
+ SynchronizationMonitor.waitUntilCurrentWindowIsRendered(ApplicationWindow.LOGIN);
+ // Cache is present the browser and we are in login page
+ toggleJMeterRequestCapture();
+ reloadOnTestStart(); // We need to check page load
+ OBConstants.WAIT_DEFAULT_RETRIES = 2000;
+ super.logIn(); // Incremental refresh login
+ SynchronizationMonitor.waitUntilCurrentWindowIsRendered(ApplicationWindow.POINTOFSALE);
+ }
+
+ @Override
+ protected void logOut() {
+ if (openTillShowed) {
+ // No further action required, already in process to return back to login in window after
+ // dismissing "Open Till" window
+ return;
+ } else if (!isLoggedInForJMeterRecording && !openTillShowed) {
+ // Make cashUp to log out and to ensure the till will be closed (opening the till will be
+ // required) for the next time to log in
+ cashUp();
+ } else {
+ super.logOut();
+ }
+ }
+
+ @Override
+ protected void preLogInActions() {
+ if (isLoggedInForJMeterRecording) {
+ setHttpRequestControllerMark("logIn");
+ }
+ super.preLogInActions();
+ }
+
+ @Override
+ protected void postLogInActions() {
+ if (checkIfInPOSWindow) {
+ super.postLogInActions();
+ } else {
+ final ArrayList<TestIdConstructor> array = new ArrayList<TestIdConstructor>();
+ array.add(TestIdExtModules.LABEL_SESSIONS_STOREISCLOSED);
+ array.add(TestIdExtModules.LABEL_SESSIONS_OPENTILL);
+ array.add(TestIdExtModules.BUTTON_SEARCH);
+ array.add(TestIdExtModules.BUTTON_SESSIONS_CONTINUE_LOGIN);
+
+ final TestIdConstructor firstFoundTestId = firstOf(array);
+ if (firstFoundTestId == TestIdExtModules.LABEL_SESSIONS_OPENTILL) {//
+ openTill();
+ } else {
+ super.postLogInActions();
+ }
+ }
+ }
+
+ @Override
+ protected void openTill() {
+ if (isLoggedInForJMeterRecording) {
+ // Test recording has started, requests for openTill controller are captured,
+ setHttpRequestControllerMark("openTill");
+ super.openTill();
+ openTillShowed = true;
+ } else if (!openTillShowed) {
+ TestIdExtModules.LABEL_SESSIONS_OPENTILL.enyoNode().waitUntilIsReady();
+ tap(TestIdExtModules.BUTTON_SESSIONS_OPENTILL_CANCEL);
+ tap(TestIdCore.BUTTON_LOGOUT);
+ openTillShowed = true;
+ toggleInPOSCheckAfterOpenTill(); // Sets flag to TRUE
+ } else {
+ super.openTill();
+ }
+ }
+
+
+ @Override
+ public void after() {
+ // Waiting for the test to complete the logout or active process
+ OBUtils.pause(7000);
+ // The test must make a log out to be able to capture the requests for such action
+ if (!MobileCoreAPI.getCurrentWindow().equals(ApplicationWindow.LOGIN)) {
+ logOut();
+ SynchronizationMonitor.waitUntilCurrentWindowIsRendered(ApplicationWindow.LOGIN);
+ }
+ // Logging back for two reasons
+ // 1. The expected ending state and verifications of the test
+ // 2. So that a "endTest" mark is sent to indicate the end of capturing for the JMeter test
+ OBConstants.WAIT_DEFAULT_RETRIES = 1500;
+ toggleJMeterRequestCapture();
+ super.logIn();
+ // SynchronizationMonitor.waitUntilCurrentWindowIsRendered(ApplicationWindow.POINTOFSALE);
+ super.after();
+ }
+
+ @Override
+ public void tap(final TestIdConstructor dom) {
+ Object dom1;
+ boolean doDelay = dom.hasWait();
+ if (isLoggedInForJMeterRecording) {
+ String currentJmeterTag = dom.evaluate();
+ if (!currentJmeterTag.equals(dom.getJMeterTag())) {
+ doDelay = false;
+ }
+ // Checks whether TestId has already been added to the static map singleTIdMap
+ if (singleTIdMap.containsKey(dom1 = dom.enyoNode().getEnyoKind())) {
+ singleTIdMap.get(dom1).handle();
+ } else {
+ // Send the HTTP jmeterTag found in the TestId
+ setHttpRequestControllerMark(currentJmeterTag);
+ }
+ }
+ super.tap(dom);
+ if (isLoggedInForJMeterRecording) {
+ conditionalSleepAfterTapOnTestId(dom, doDelay);
+ }
+ }
+
+ /**
+ * Executes Sleep necessary after clicking on certain buttons, to ensure that all requests are
+ * properly collected
+ *
+ * @param dom
+ * @param doDelay
+ */
+ private void conditionalSleepAfterTapOnTestId(final TestIdConstructor dom, final boolean doDelay) {
+ if (isProxyActive) {
+ if (doDelay) {
+ // TODO: Ensure that all of the requests for the controller names that require it are
+ // correctly captured
+ // SynchronizationMonitor.waitUntiTheApplicationHasSynchronized();
+ OBUtils.pause(30000);
+ }
+ }
+ }
+
+ @Override
+ public void reload() {
+ setHttpRequestControllerMark("incrementalRefresh");
+ super.reload();
+ }
+
+ /**
+ * Reloads web browser on test start
+ */
+ private void reloadOnTestStart() {
+ OBUtils.pause(3000);
+ super.reload();
+ }
+
+ /**
+ * Makes a Cash Up
+ */
+ private void cashUp() {
+ /** cashUp **/
+ tap(TestIdPack.BUTTON_MENU);
+ tap(TestIdPack.BUTTON_MENU_CASHUP);
+ tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_010);
+ tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_050);
+ tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_1);
+ tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_2);
+
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ tap(TestIdPack.BUTTON_CASHUP_CARD_OK);
+ tap(TestIdPack.BUTTON_CASHUP_CASHUSA_OK);
+ tap(TestIdPack.BUTTON_CASHUP_VOUCHER_OK);
+
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ tap(TestIdPack.BUTTON_CASHUP_KEEPNOTHING);
+
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ tap(TestIdPack.BUTTON_CASHUP_KEEPNOTHING);
+
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ tap(TestIdPack.BUTTON_CASHUP_KEEPNOTHING);
+
+ tap(TestIdPack.BUTTON_CASHUP_NEXT);
+ tap(TestIdPack.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+ tap(TestIdPack.BUTTON_POPUP_OK);
+ // Waiting for the test to complete the logout or cash up
+ OBUtils.pause(7000);
+ }
+
+ /**
+ * Toggles the feature of inserting marks which will indicate the start and end of the test.
+ * Usage: toggled once the the cache is loaded prior starting the actual test, and to be toggled
+ * again once the marks end
+ */
+ private void toggleJMeterRequestCapture() {
+ if (!isLoggedInForJMeterRecording) {
+ setHttpRequestControllerMark("loadLoginPage");
+ } else {
+ setHttpRequestControllerMark("endTest");
+ }
+ isLoggedInForJMeterRecording = !isLoggedInForJMeterRecording;
+ }
+
+ /**
+ *
+ */
+ private void toggleInPOSCheckAfterOpenTill() {
+ checkIfInPOSWindow = !checkIfInPOSWindow;
+ }
+}
\ No newline at end of file
|