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
|
@ -58,7 +58,14 @@ public class AdempiereIdGenerator implements IdGenerator {
|
||||||
.append("=\'").append(attribute).append("']");
|
.append("=\'").append(attribute).append("']");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
locatorBuilder.append("$").append(prefix);
|
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) {
|
if (prefix == null || prefix.length() == 0) {
|
||||||
|
@ -74,7 +81,12 @@ public class AdempiereIdGenerator implements IdGenerator {
|
||||||
String id = parent.getId();
|
String id = parent.getId();
|
||||||
if (id != null && id.length() > 0) {
|
if (id != null && id.length() > 0) {
|
||||||
builder.insert(0, id+"_");
|
builder.insert(0, id+"_");
|
||||||
locatorBuilder.insert(0, "$"+id+" ");
|
if (id.indexOf(" ") > 0) {
|
||||||
|
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||||
|
locatorBuilder.insert(0, "@"+widgetName+"[id=\'"+id+"\'] ");
|
||||||
|
} else {
|
||||||
|
locatorBuilder.insert(0, "$"+id+" ");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
||||||
if (attribute != null && attribute.length() > 0) {
|
if (attribute != null && attribute.length() > 0) {
|
||||||
|
@ -162,7 +174,14 @@ public class AdempiereIdGenerator implements IdGenerator {
|
||||||
.append("=\'").append(attribute).append("']");
|
.append("=\'").append(attribute).append("']");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
locatorBuilder.append("$").append(prefix);
|
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) {
|
if (prefix == null || prefix.length() == 0) {
|
||||||
|
@ -175,7 +194,12 @@ public class AdempiereIdGenerator implements IdGenerator {
|
||||||
if (parent instanceof IdSpace) {
|
if (parent instanceof IdSpace) {
|
||||||
String id = parent.getId();
|
String id = parent.getId();
|
||||||
if (id != null && id.length() > 0) {
|
if (id != null && id.length() > 0) {
|
||||||
locatorBuilder.insert(0, "$"+id+" ");
|
if (id.indexOf(" ") > 0) {
|
||||||
|
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||||
|
locatorBuilder.insert(0, "@"+widgetName+"[id=\'"+id+"\'] ");
|
||||||
|
} else {
|
||||||
|
locatorBuilder.insert(0, "$"+id+" ");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
||||||
if (attribute != null && attribute.length() > 0) {
|
if (attribute != null && attribute.length() > 0) {
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class ZkFixture extends SpiderFixture {
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------- ComboBox ---------
|
// --------- ComboBox ---------
|
||||||
|
@SimpleAction(wiki = "|''<i>combobox</i>''|zk locator|''<i>selected value</i>''|", tooltip = "Return current selected value")
|
||||||
public String comboboxSelectedValue(String locator) {
|
public String comboboxSelectedValue(String locator) {
|
||||||
Widget widget = new Widget(locator);
|
Widget widget = new Widget(locator);
|
||||||
return (String) widget.eval(webDriver, "getValue()");
|
return (String) widget.eval(webDriver, "getValue()");
|
||||||
|
@ -88,6 +89,7 @@ public class ZkFixture extends SpiderFixture {
|
||||||
return false;
|
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) {
|
public boolean comboboxSetText(String locator, String text) {
|
||||||
Widget widget = new Widget(locator);
|
Widget widget = new Widget(locator);
|
||||||
widget.execute(webDriver, "setValue('"+text+"', true)");
|
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) {
|
public void focus(String locator) {
|
||||||
Widget widget = new Widget(locator);
|
Widget widget = new Widget(locator);
|
||||||
widget.execute(webDriver, "focus()");
|
widget.execute(webDriver, "focus_(100)");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getEval(String script) {
|
@SimpleAction(wiki = "|''<i>with widget</i>''|zk locator|''<i>execute</i>''|command|", tooltip = "Execute zk widget command")
|
||||||
return String.valueOf(executeJavaScript("return ("+ script+");"));
|
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.
|
* and schedulers. The thread does not lose ownership of any monitors.
|
||||||
* @param millis the length of time to sleep in milliseconds.
|
* @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 {
|
try {
|
||||||
Thread.sleep(millis);
|
Thread.sleep(millis);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getEval(String script) {
|
||||||
|
return String.valueOf(executeJavaScript("return ("+ script+");"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ZkFinder implements Finder {
|
class ZkFinder implements Finder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class Widget extends By {
|
||||||
public void execute(WebDriver driver, String command) {
|
public void execute(WebDriver driver, String command) {
|
||||||
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
||||||
StringBuilder builder = getWidgetLocatorScript(locator);
|
StringBuilder builder = getWidgetLocatorScript(locator);
|
||||||
|
command = command.replace("'", "\\'");
|
||||||
builder.append(".").append(command).append(";");
|
builder.append(".").append(command).append(";");
|
||||||
executor.executeScript(builder.toString());
|
executor.executeScript(builder.toString());
|
||||||
}
|
}
|
||||||
|
@ -60,6 +61,7 @@ public class Widget extends By {
|
||||||
public Object eval(WebDriver driver, String command) {
|
public Object eval(WebDriver driver, String command) {
|
||||||
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
||||||
StringBuilder builder = getWidgetLocatorScript(locator);
|
StringBuilder builder = getWidgetLocatorScript(locator);
|
||||||
|
command = command.replace("'", "\\'");
|
||||||
builder.insert(0, "return ");
|
builder.insert(0, "return ");
|
||||||
builder.append(".").append(command).append(";");
|
builder.append(".").append(command).append(";");
|
||||||
return executor.executeScript(builder.toString());
|
return executor.executeScript(builder.toString());
|
||||||
|
|
Loading…
Reference in New Issue