IDEMPIERE-92 Implement Selenium testing framework. Fixed combobox issue after the 6.5.1 upgrade.

This commit is contained in:
Heng Sin Low 2013-01-11 13:24:07 +08:00
parent a63999e429
commit 095c72be64
3 changed files with 34 additions and 9 deletions

View File

@ -4,7 +4,7 @@ Bugs: Field translation tab not show
!include -c ZkSystemAdminLogin
'''Open Window, Tab & Field'''
|''combobox''|$treeSearchCombo|''select item''|!-Window, Tab & Field-!|
|''open window''|!-Window, Tab & Field-!|
|''wait response''|
|''click''|$findWindow_1 $simpleSearch $btnOk|

View File

@ -49,18 +49,26 @@ public class ZkFixture extends SpiderFixture {
// --------- ComboBox ---------
public String comboboxSelectedValue(String 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.")
public boolean comboboxSelectItem(String locator, String label) {
Widget widget = new Widget(locator);
widget.execute(webDriver, "setValue('"+label+"')");
widget.execute(webDriver, "fireOnChange()");
WebElement element = widget.$n(webDriver, "real");
element.click();
widget.execute(webDriver, "open()");
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.")
@ -77,7 +85,18 @@ public class ZkFixture extends SpiderFixture {
}
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 ----
@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) {
@ -111,7 +130,7 @@ public class ZkFixture extends SpiderFixture {
// ---- window ( tab ) ---
@SimpleAction(wiki = "|''<i>open window</i>''|menu label|", tooltip = "Open window with 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.")

View File

@ -54,4 +54,10 @@ public class Widget extends By {
JavascriptExecutor executor = (JavascriptExecutor) driver;
return executor.executeScript("return zk('"+locator+"').$()."+command+";");
}
public static StringBuilder getWidgetLocatorScript(String locator) {
StringBuilder builder = new StringBuilder("zk('");
builder.append(locator).append("').$()");
return builder;
}
}