IDEMPIERE-92 Implement Selenium testing framework. Fixed combobox issue after the 6.5.1 upgrade.
This commit is contained in:
parent
a63999e429
commit
095c72be64
|
@ -4,7 +4,7 @@ Bugs: Field translation tab not show
|
||||||
!include -c ZkSystemAdminLogin
|
!include -c ZkSystemAdminLogin
|
||||||
|
|
||||||
'''Open Window, Tab & Field'''
|
'''Open Window, Tab & Field'''
|
||||||
|''combobox''|$treeSearchCombo|''select item''|!-Window, Tab & Field-!|
|
|''open window''|!-Window, Tab & Field-!|
|
||||||
|''wait response''|
|
|''wait response''|
|
||||||
|''click''|$findWindow_1 $simpleSearch $btnOk|
|
|''click''|$findWindow_1 $simpleSearch $btnOk|
|
||||||
|
|
||||||
|
|
|
@ -49,18 +49,26 @@ public class ZkFixture extends SpiderFixture {
|
||||||
// --------- ComboBox ---------
|
// --------- ComboBox ---------
|
||||||
public String comboboxSelectedValue(String locator) {
|
public String comboboxSelectedValue(String locator) {
|
||||||
Widget widget = new Widget(locator);
|
Widget widget = new Widget(locator);
|
||||||
return widget.$n(webDriver, "real").getAttribute("Value");
|
return (String) widget.eval(webDriver, "getValue()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SimpleAction(wiki = "|''<i>combobox</i>''|xpath, id or other locator|''<i>select item</i>''|label of item|", tooltip = "Changes the selected item in the given comboBox.")
|
@SimpleAction(wiki = "|''<i>combobox</i>''|xpath, id or other locator|''<i>select item</i>''|label of item|", tooltip = "Changes the selected item in the given comboBox.")
|
||||||
public boolean comboboxSelectItem(String locator, String label) {
|
public boolean comboboxSelectItem(String locator, String label) {
|
||||||
Widget widget = new Widget(locator);
|
Widget widget = new Widget(locator);
|
||||||
widget.execute(webDriver, "setValue('"+label+"')");
|
widget.execute(webDriver, "open()");
|
||||||
widget.execute(webDriver, "fireOnChange()");
|
|
||||||
WebElement element = widget.$n(webDriver, "real");
|
|
||||||
element.click();
|
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return label.equals(element.getAttribute("value"));
|
List<WebElement> list = webDriver.findElements(Zk.jq(locator + " @comboitem"));
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
for(WebElement element : list) {
|
||||||
|
if (element.getText().equals(label) || element.getText().trim().equals(label)) {
|
||||||
|
element.click();
|
||||||
|
waitResponse();
|
||||||
|
String selected = comboboxSelectedValue(locator);
|
||||||
|
return label.equals(selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SimpleAction(wiki = "|''<i>combobox</i>''|xpath, id or other locator|''<i>select item at</i>''|index|", tooltip = "Changes the selected item to the nth one, in the given comboBox.")
|
@SimpleAction(wiki = "|''<i>combobox</i>''|xpath, id or other locator|''<i>select item at</i>''|index|", tooltip = "Changes the selected item to the nth one, in the given comboBox.")
|
||||||
|
@ -78,6 +86,17 @@ public class ZkFixture extends SpiderFixture {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean comboboxSetText(String locator, String text) {
|
||||||
|
Widget widget = new Widget(locator);
|
||||||
|
widget.execute(webDriver, "setValue('"+text+"', true)");
|
||||||
|
widget.execute(webDriver, "fireOnChange()");
|
||||||
|
WebElement element = widget.$n(webDriver, "real");
|
||||||
|
element.click();
|
||||||
|
waitResponse();
|
||||||
|
|
||||||
|
return text.equals(comboboxSelectedValue(locator));
|
||||||
|
}
|
||||||
|
|
||||||
// ---- Tabbox ----
|
// ---- Tabbox ----
|
||||||
@SimpleAction(wiki = "|''<i>tabbox</i>''|xpath, id or other locator|''<i>select tab at</i>''|index|", tooltip = "Changes the selected tab to the nth one, in the given tabbox.")
|
@SimpleAction(wiki = "|''<i>tabbox</i>''|xpath, id or other locator|''<i>select tab at</i>''|index|", tooltip = "Changes the selected tab to the nth one, in the given tabbox.")
|
||||||
public void tabboxSelectTabAt(String locator, int index) {
|
public void tabboxSelectTabAt(String locator, int index) {
|
||||||
|
@ -111,7 +130,7 @@ public class ZkFixture extends SpiderFixture {
|
||||||
// ---- window ( tab ) ---
|
// ---- window ( tab ) ---
|
||||||
@SimpleAction(wiki = "|''<i>open window</i>''|menu label|", tooltip = "Open window with label.")
|
@SimpleAction(wiki = "|''<i>open window</i>''|menu label|", tooltip = "Open window with label.")
|
||||||
public void openWindow(String label) {
|
public void openWindow(String label) {
|
||||||
comboboxSelectItem("$treeSearchCombo", label);
|
comboboxSetText("$treeSearchCombo", label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SimpleAction(wiki = "|''<i>window</i>''|xpath, id or other locator|''<i>click process button</i>''|button id|", tooltip = "Click a window's process button.")
|
@SimpleAction(wiki = "|''<i>window</i>''|xpath, id or other locator|''<i>click process button</i>''|button id|", tooltip = "Click a window's process button.")
|
||||||
|
|
|
@ -54,4 +54,10 @@ public class Widget extends By {
|
||||||
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
||||||
return executor.executeScript("return zk('"+locator+"').$()."+command+";");
|
return executor.executeScript("return zk('"+locator+"').$()."+command+";");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StringBuilder getWidgetLocatorScript(String locator) {
|
||||||
|
StringBuilder builder = new StringBuilder("zk('");
|
||||||
|
builder.append(locator).append("').$()");
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue