IDEMPIERE-92 Implement Selenium testing framework. Fixed _zk_locator for id with space. Added execution of arbitrary zk widget command support to zk fixture.
This commit is contained in:
parent
1c718c74a9
commit
ac0d909eac
|
@ -57,9 +57,16 @@ public class AdempiereIdGenerator implements IdGenerator {
|
|||
.append(AdempiereWebUI.WIDGET_INSTANCE_NAME)
|
||||
.append("=\'").append(attribute).append("']");
|
||||
}
|
||||
} else {
|
||||
if (prefix.indexOf(" ") > 0) {
|
||||
String widgetName = getWidgetName(comp.getWidgetClass());
|
||||
locatorBuilder.append("@")
|
||||
.append(widgetName).append("[id")
|
||||
.append("=\'").append(prefix).append("']");
|
||||
} else {
|
||||
locatorBuilder.append("$").append(prefix);
|
||||
}
|
||||
}
|
||||
|
||||
if (prefix == null || prefix.length() == 0) {
|
||||
prefix = DEFAULT_ZK_COMP_PREFIX;
|
||||
|
@ -74,7 +81,12 @@ public class AdempiereIdGenerator implements IdGenerator {
|
|||
String id = parent.getId();
|
||||
if (id != null && id.length() > 0) {
|
||||
builder.insert(0, id+"_");
|
||||
if (id.indexOf(" ") > 0) {
|
||||
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||
locatorBuilder.insert(0, "@"+widgetName+"[id=\'"+id+"\'] ");
|
||||
} else {
|
||||
locatorBuilder.insert(0, "$"+id+" ");
|
||||
}
|
||||
} else {
|
||||
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
||||
if (attribute != null && attribute.length() > 0) {
|
||||
|
@ -161,9 +173,16 @@ public class AdempiereIdGenerator implements IdGenerator {
|
|||
.append(AdempiereWebUI.WIDGET_INSTANCE_NAME)
|
||||
.append("=\'").append(attribute).append("']");
|
||||
}
|
||||
} else {
|
||||
if (prefix.indexOf(" ") > 0) {
|
||||
String widgetName = getWidgetName(comp.getWidgetClass());
|
||||
locatorBuilder.append("@")
|
||||
.append(widgetName).append("[id")
|
||||
.append("=\'").append(prefix).append("']");
|
||||
} else {
|
||||
locatorBuilder.append("$").append(prefix);
|
||||
}
|
||||
}
|
||||
|
||||
if (prefix == null || prefix.length() == 0) {
|
||||
locatorBuilder.append("@").append(getWidgetName(comp.getWidgetClass()));
|
||||
|
@ -175,7 +194,12 @@ public class AdempiereIdGenerator implements IdGenerator {
|
|||
if (parent instanceof IdSpace) {
|
||||
String id = parent.getId();
|
||||
if (id != null && id.length() > 0) {
|
||||
if (id.indexOf(" ") > 0) {
|
||||
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||
locatorBuilder.insert(0, "@"+widgetName+"[id=\'"+id+"\'] ");
|
||||
} else {
|
||||
locatorBuilder.insert(0, "$"+id+" ");
|
||||
}
|
||||
} else {
|
||||
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
||||
if (attribute != null && attribute.length() > 0) {
|
||||
|
|
|
@ -47,6 +47,7 @@ public class ZkFixture extends SpiderFixture {
|
|||
}
|
||||
|
||||
// --------- ComboBox ---------
|
||||
@SimpleAction(wiki = "|''<i>combobox</i>''|zk locator|''<i>selected value</i>''|", tooltip = "Return current selected value")
|
||||
public String comboboxSelectedValue(String locator) {
|
||||
Widget widget = new Widget(locator);
|
||||
return (String) widget.eval(webDriver, "getValue()");
|
||||
|
@ -88,6 +89,7 @@ public class ZkFixture extends SpiderFixture {
|
|||
return false;
|
||||
}
|
||||
|
||||
@SimpleAction(wiki= "|''<i>combobox</i>''|zk locator|''<i>set text</i>''|text|", tooltip = "Enter text into combobox and fire onChange event")
|
||||
public boolean comboboxSetText(String locator, String text) {
|
||||
Widget widget = new Widget(locator);
|
||||
widget.execute(webDriver, "setValue('"+text+"', true)");
|
||||
|
@ -199,13 +201,22 @@ public class ZkFixture extends SpiderFixture {
|
|||
}
|
||||
}
|
||||
|
||||
@SimpleAction(wiki="|''<i>focus</i>''|xpath, id or other locator|", tooltip= "Set focus to a zk widget")
|
||||
public void focus(String locator) {
|
||||
Widget widget = new Widget(locator);
|
||||
widget.execute(webDriver, "focus()");
|
||||
widget.execute(webDriver, "focus_(100)");
|
||||
}
|
||||
|
||||
protected String getEval(String script) {
|
||||
return String.valueOf(executeJavaScript("return ("+ script+");"));
|
||||
@SimpleAction(wiki = "|''<i>with widget</i>''|zk locator|''<i>execute</i>''|command|", tooltip = "Execute zk widget command")
|
||||
public void withWidgetExecute(String locator, String command) {
|
||||
Widget widget = new Widget(locator);
|
||||
widget.execute(webDriver, command);
|
||||
}
|
||||
|
||||
@SimpleAction(wiki = "|''<i>with widget</i>''|zk locator|''<i>eval</i>''|command|", tooltip = "Execute zk widget command and return the result")
|
||||
public Object withWidgetEval(String locator, String command) {
|
||||
Widget widget = new Widget(locator);
|
||||
return widget.eval(webDriver, command);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -214,13 +225,20 @@ public class ZkFixture extends SpiderFixture {
|
|||
* and schedulers. The thread does not lose ownership of any monitors.
|
||||
* @param millis the length of time to sleep in milliseconds.
|
||||
*/
|
||||
protected void sleep(long millis) {
|
||||
@SimpleAction(wiki = "|''<i>sleep</i>''|millisecond|", tooltip = "sleep")
|
||||
public void sleep(long millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
protected String getEval(String script) {
|
||||
return String.valueOf(executeJavaScript("return ("+ script+");"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
class ZkFinder implements Finder {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,6 +53,7 @@ public class Widget extends By {
|
|||
public void execute(WebDriver driver, String command) {
|
||||
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
||||
StringBuilder builder = getWidgetLocatorScript(locator);
|
||||
command = command.replace("'", "\\'");
|
||||
builder.append(".").append(command).append(";");
|
||||
executor.executeScript(builder.toString());
|
||||
}
|
||||
|
@ -60,6 +61,7 @@ public class Widget extends By {
|
|||
public Object eval(WebDriver driver, String command) {
|
||||
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
||||
StringBuilder builder = getWidgetLocatorScript(locator);
|
||||
command = command.replace("'", "\\'");
|
||||
builder.insert(0, "return ");
|
||||
builder.append(".").append(command).append(";");
|
||||
return executor.executeScript(builder.toString());
|
||||
|
|
Loading…
Reference in New Issue