IDEMPIERE-92 Implement Selenium testing framework. Handle single quote in zk selector.
This commit is contained in:
parent
ebb76fd02c
commit
f0806d82ab
|
@ -37,25 +37,36 @@ public class Widget extends By {
|
|||
|
||||
private WebElement findElement(WebDriver driver) {
|
||||
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
||||
return (WebElement) executor.executeScript("return zk('"+locator+"').$().$n();");
|
||||
StringBuilder builder = getWidgetLocatorScript(locator);
|
||||
builder.insert(0, "return ").append(".$n();");
|
||||
return (WebElement) executor.executeScript(builder.toString());
|
||||
}
|
||||
|
||||
public WebElement $n(WebDriver driver, String subName) {
|
||||
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
||||
return (WebElement) executor.executeScript("return zk('"+locator+"').$().$n('"+subName+"');");
|
||||
StringBuilder builder = getWidgetLocatorScript(locator);
|
||||
builder.insert(0, "return ")
|
||||
.append(".$n('").append(subName).append("');");
|
||||
return (WebElement) executor.executeScript(builder.toString());
|
||||
}
|
||||
|
||||
public void execute(WebDriver driver, String command) {
|
||||
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
||||
executor.executeScript("zk('"+locator+"').$()."+command+";");
|
||||
StringBuilder builder = getWidgetLocatorScript(locator);
|
||||
builder.append(".").append(command).append(";");
|
||||
executor.executeScript(builder.toString());
|
||||
}
|
||||
|
||||
public Object eval(WebDriver driver, String command) {
|
||||
JavascriptExecutor executor = (JavascriptExecutor) driver;
|
||||
return executor.executeScript("return zk('"+locator+"').$()."+command+";");
|
||||
StringBuilder builder = getWidgetLocatorScript(locator);
|
||||
builder.insert(0, "return ");
|
||||
builder.append(".").append(command).append(";");
|
||||
return executor.executeScript(builder.toString());
|
||||
}
|
||||
|
||||
public static StringBuilder getWidgetLocatorScript(String locator) {
|
||||
locator = locator.replace("'", "\\'");
|
||||
StringBuilder builder = new StringBuilder("zk('");
|
||||
builder.append(locator).append("').$()");
|
||||
return builder;
|
||||
|
|
|
@ -34,6 +34,7 @@ public class Zk {
|
|||
public List<WebElement> findElements(SearchContext context) {
|
||||
JavascriptExecutor executor = null;
|
||||
String selector = this.selector;
|
||||
selector = selector.replace("'", "\\'");
|
||||
if (context instanceof WebDriver) {
|
||||
executor = (JavascriptExecutor) context;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue