Commit 4ed4f6bb authored by holivier's avatar holivier

First release for ExampleMgmtPg test

parent 77b43efa
......@@ -294,6 +294,10 @@
<value xml:lang="en">Pb showing portlet </value>
<value xml:lang="fr">Problème d'affichage de la portlet </value>
</property>
<property key="pbWithScreenlet">
<value xml:lang="en">Pb showing screenlet </value>
<value xml:lang="fr">Problème d'affichage de la screenlet </value>
</property>
<property key="pbWithForm">
<value xml:lang="en">Pb showing form </value>
<value xml:lang="fr">Problème d'affichage de la form </value>
......
......@@ -109,7 +109,7 @@ public class LogSelenium {
if (infoPanelEnabled()) {
if (wdtc.isVuejs() ) {
js.executeScript("window.showSeleniumInfoPanel({panelMessage: '"
+ StringEscapeUtils.escapeJavaScript(message)
+ StringEscapeUtils.escapeJavaScript(message) // TODO Vue.Js escape/sanitize automatically, so can be remove, should be tested
+ "',panelTimeout: "+seconds * 1000 +"})", new Object[]{ null }); // two other parameter exist panelTitle and panelColor
} else {
js.executeScript("showSeleniumInfoPanel('" + StringEscapeUtils.escapeJavaScript(message) +"', '" + seconds * 1000 + "')", new Object[]{ null });
......
......@@ -708,7 +708,7 @@ public class OfbizSWdHelper {
}
/**
* Click on keyId as a link in a div#id
* Click on keyId as a link in a div#id (for vuejs env)
* @param testSuite
* @param divId
* @param keyId
......@@ -742,6 +742,20 @@ public class OfbizSWdHelper {
clickOnLinkKey(testSuite, "vue-portlet_" + portletName + "-00001", keyId);
}
/**
* test if screenlet with div#screenletId is present and if title is screenletDesc
* @param testSuite
* @param screenletId for screenlet the default id is screenletId+"-"(+ screenletName, most of the time null/empty)
* @param screenletDesc
* @throws Exception
*/
public static void testScreenletIsOk(SimpleTestSuite testSuite, String screenletId, String screenletDesc) throws Exception {
ResourceBundle userLabel = testSuite.getUserLabel();
WebDriver driver = testSuite.getDriver();
assertEquals(userLabel.getString("pbWithScreenlet")+screenletId,
screenletDesc,
driver.findElement(By.cssSelector("div#"+screenletId+"- header.screenlet-title-bar div.title")).getText());
}
/**
* test if portletName is present and if title is portletDesc
* @param testSuite
......@@ -805,6 +819,57 @@ public class OfbizSWdHelper {
// driver.findElement(By.cssSelector("label[idname='"+ idName + "_o_" + nbLine+ "']")).getAttribute("description")); 2020-01-13
}
/**
* Click on the menuName button in the screnletTitle bar for the div with divId.
* <br/>Test if portlet menu is with a openMenu button, if yes click on it,
* <br/>find all menu items, and if getText == menuName, click on it.
* <br/>if menu item not found, try 5 times to reload menu item list after waiting 0.5s.
* <br/>if menuName is null search on iconId (span#iconId)
* @param testSuite
* @param divId for screenlet the default id is screenletId+"-"(+ screenletName, most of the time null/empty)
* @param menuName if not null search on this name
* @param iconId if menuName is null, search a span#iconId, most of icon have a id mdi-xxx (ex: mdi-pencil for edit)
* @throws Exception
*/
public static void clickScreenletSubmenu(SimpleTestSuite testSuite, String divId, String menuName, String iconId) throws Exception {
WebDriver driver = testSuite.getDriver();
List<WebElement> menuItems = null;
// open menu if there is the menu button
if (driver.findElements(By.cssSelector("div#" + divId + " header.screenlet-title-bar button span#mdi-dots-vertical")).size() > 0) {
WebElement menuButton = driver.findElement(By.cssSelector("div#" + divId + " header.screenlet-title-bar button span#mdi-dots-vertical"));
menuButton.click();
}
int try5 = 0;
boolean found = false;
do {
if (driver.findElements(By.cssSelector("div#" + divId + " header.screenlet-title-bar button span#mdi-dots-vertical")).size() > 0) {
menuItems = driver.findElements(By.cssSelector("div.v-menu__content div.v-list div#vue-link > span"));
} else {
menuItems = driver.findElements(By.cssSelector("div#" + divId + " header.screenlet-title-bar button > span"));
}
for (WebElement menuItem : menuItems) {
// double test lowerCase and UpperCase because depending on theme
if (LogSelenium.verboseOn()) LogSelenium.verbose(module, "clickPortletSubmenu : " + menuItem.getText());
if ( menuName != null ){
if (menuName.equals(menuItem.getText()) || menuName.toUpperCase().equals(menuItem.getText())) {
testSuite.click(menuItem);
found = true;
}
} else {
if ( menuItem.findElements(By.cssSelector("span#"+iconId)).size() > 0) {
testSuite.click(menuItem);
found = true;
}
}
}
if (!found) {
// wait 0.5s, because html dom seem to not be complete
try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); }
try5++;
}
} while (!found && try5 < 5);
assertTrue("menu with name/icon" + menuName+"/"+iconId + " not found for screenlet " + divId, found);
}
/**
* Click on the menuName button in the screnletTitle bar for the portlet portletName.
* <br/>Test if portlet menu is with a openMenu button, if yes click on it,
......
......@@ -26,7 +26,7 @@ public class ExampleVueJsScreens {
private static final String module = ExampleVueJsScreens.class.getName();
/**
* Populate field of search form and click on search button.
* Populate field of search form (FindExamples) and click on search button.
* @param testSuite the current test object
* @param criteria it could contains (all fields are optional)
* <ul>
......@@ -100,6 +100,21 @@ public class ExampleVueJsScreens {
search(testSuite, criteria, null);
}
/**
* test if containerId is present but include nothing (only one div)
* @param testSuite
* @param containerId
* @throws Exception
*/
public static void testContainerIsEmpty(SimpleTestSuite testSuite, String containerId) throws Exception {
ResourceBundle userLabel = testSuite.getUserLabel();
WebDriver driver = testSuite.getDriver();
WebElement portlet = driver.findElement(By.cssSelector("div#"+containerId));
assertEquals(userLabel.getString("pbWithContainer ")+containerId,
1,
portlet.findElements(By.cssSelector("div")).size());
}
/**
* test if portletName is present but include nothing (only one div)
* @param testSuite
......@@ -130,6 +145,20 @@ public class ExampleVueJsScreens {
driver.findElement(By.cssSelector("#vue-form_"+formName+" input[name='submitButton']")).getAttribute("value"));
}
/**
* return number of row there are in list in a div#divId.
* @param testSuite
* @param divId
* @return nbLine By.cssSelector("tr#vue-item-row")).size() in div#"+divId
* @throws Exception
*/
public static int howNbLineInListById(SimpleTestSuite testSuite, String divId) throws Exception {
WebDriver driver = testSuite.getDriver();
testSuite.waitLoaderWrapper();
WebElement weForm = driver.findElement(By.cssSelector("div#"+divId));
return weForm.findElements(By.cssSelector("tr#vue-item-row")).size();
}
/**
* return number of row there are in list in portletName.
* @param testSuite
......@@ -146,6 +175,20 @@ public class ExampleVueJsScreens {
}
/**
* test if Nav Bar is present (or not) in div divId
* @param testSuite
* @param divId
* @param present true if navbar should be there, otherwise false
* @throws Exception
*/
public static void testNavBarById(SimpleTestSuite testSuite, String divId, boolean present) throws Exception {
ResourceBundle userLabel = testSuite.getUserLabel();
WebDriver driver = testSuite.getDriver();
assertEquals(userLabel.getString("pbWithScreenlet")+divId,
present,
driver.findElements(By.cssSelector("div#"+divId+" div#vue-next-prev" )).size()>0);
}
/**
* test if Nav Bar is present (or not) in portlet portletName
* @param testSuite
......@@ -511,12 +554,38 @@ public class ExampleVueJsScreens {
}
/**
* click on button GotoRecapPage in portlet ExampleDetailMenu
* click on button GotoRecapPage in screenlet detailMenu
* @param testSuite
* @param logMessage if null message GotoRecapPage is used
* @throws Exception
*/
public static void detailMenuGotoRecap(SimpleTestSuite testSuite, String logMessage) throws Exception {
ResourceBundle userLabel = testSuite.getUserLabel();
LogSelenium.showInfoPanel(module, testSuite,
(logMessage != null) ? logMessage : userLabel.getString("GotoRecapPage"));
WebDriver driver = testSuite.getDriver();
WebElement portlet = driver.findElement(By.id("detailMenu"));
// click on second button in external menu
List<WebElement> items = portlet.findElements(By.cssSelector("header#vue-menu button a span"));
WebElement button = null;
for (WebElement item : items) {
if (item.getText().equals("Recap Page")) {
button = item;
}
}
if (button != null) {
testSuite.click(button);
} else {
throw new NotFoundException("Button 'Recap Page' not Found");
}
}
/**
* click on button GotoRecapPage in portlet ExampleDetailMenu
* @param testSuite
* @param logMessage if null message GotoRecapPage is used
* @throws Exception
*/
public static void detailMenuPortletGotoRecap(SimpleTestSuite testSuite, String logMessage) throws Exception {
ResourceBundle userLabel = testSuite.getUserLabel();
LogSelenium.showInfoPanel(module, testSuite,
(logMessage != null) ? logMessage : userLabel.getString("GotoRecapPage"));
......
......@@ -169,7 +169,7 @@
</test-case>
</test-suite>
<test-suite name="ExampleVuejsTestSuite">
<test-case name="exampleRecapFrontJs">
<test-case name="exampleRecapPPFrontJs">
<extend-object data-obj="updateEx2Status1" test-case="exampleOverview" test-suite="ExampleScreensOverview" scenario="default"/>
<extend-object data-obj="updateEx2Status2" test-case="exampleOverview" test-suite="ExampleScreensOverview" scenario="default"/>
<data-obj name="login">
......@@ -216,7 +216,7 @@
<string name="exampleTypeId" value="MADE_UP"/>
</data-obj>
</test-case>
<test-case name="exampleMgmtFrontJs">
<test-case name="exampleMgmtPPFrontJs">
<extend-object data-obj="login" test-case="exampleRecapFrontJs" test-suite="ExampleVuejsTestSuite" scenario="default"/>
<data-obj name="menuFjsMgmt">
<integer name="menuNum" value="-1"/>
......@@ -247,6 +247,38 @@
<string name="amount" value="20"/>
</data-obj>
</test-case>
<test-case name="exampleMgmtPg">
<extend-object data-obj="login" test-case="exampleRecapFrontJs" test-suite="ExampleVuejsTestSuite" scenario="default"/>
<data-obj name="menuMgmtPg">
<integer name="menuNum" value="-1"/>
<string name="optionName" value="Examples management"/>
</data-obj>
<extend-object data-obj="criteria_empty" test-case="exampleOverview" test-suite="ExampleScreensOverview" scenario="default"/>
<extend-object data-obj="criteria_Id1" test-case="exampleOverview" test-suite="ExampleScreensOverview" scenario="default"/>
<extend-object data-obj="criteria_Id2" test-case="exampleOverview" test-suite="ExampleScreensOverview" scenario="default"/>
<extend-object data-obj="updateEx2Status1" test-case="exampleOverview" test-suite="ExampleScreensOverview" scenario="default"/>
<extend-object data-obj="updateEx2Status2" test-case="exampleOverview" test-suite="ExampleScreensOverview" scenario="default"/>
<extend-object data-obj="updateEx2Status3" test-case="exampleRecapFrontJs" test-suite="ExampleVuejsTestSuite" scenario="default"/>
<data-obj name="exTest3">
<string name="exampleIdRef" value="EX10"/>
<indexed name="exampleId" value="EX1"/>
<indexed name="exampleName" value="Gxample after update3 EX1"/>
<indexed name="description" value="upd3 Selenium-1"/>
<string name="longDescription" value="test3 about long desc"/>
<string name="longDescription2" value="this is the second line 3"/>
<string name="longDescription3" value="and the third-3"/>
</data-obj>
<data-obj name="item1">
<string name="description" value="place surface SC"/>
<string name="amount" value="13"/>
<string name="uom" value="Area: Square Meter (m2)"/>
<indexed name="nbRun" value=""/>
</data-obj>
<data-obj name="item1.1">
<string name="description" value="more place surface SC"/>
<string name="amount" value="23"/>
</data-obj>
</test-case>
</test-suite>
</scenario>
</testdata>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment