我已经完成了一些示例代码,在 Flash 页面中使用 webdriver 选择组合框,但 Select(...) 和 type(....) 方法不起作用,但 click(....) 方法工作正常。
请帮忙解决这个问题。 Type-1:以下方法不起作用。
public void type(String locator, String value)
{
((JavascriptExecutor) webDriver).executeScript("document.getElementById('" + flashObjectId + "').fp_type({" + locator +", 'text':'"+ value +"'})");
}
public void select(String locator, String value)
{
((JavascriptExecutor) webDriver).executeScript("document.getElementById('" + flashObjectId + "').fp_select({" + locator +", 'label':'"+ value +"'})");
}
它在下面的 click(....) 方法中工作正常。
public String click(final String objectId, final String optionalButtonLabel)
{
return call("doFlexClick", objectId, optionalButtonLabel);
}
private String call(final String functionName, final String... args)
{
final Object result =
((JavascriptExecutor)webDriver).executeScript(
makeJsFunction(functionName, args),
new Object[0]);
return result != null ? result.toString() : null;
}
private String makeJsFunction(final String functionName, final String... args)
{
final StringBuffer functionArgs = new StringBuffer();
if (args.length > 0)
{
for (int i = 0; i < args.length; i++)
{
if (i > 0)
{
functionArgs.append(",");
}
functionArgs.append(String.format("'%1$s'", args[i]));
System.out.println("functionArgs: "+functionArgs);
}
}
return String.format(
"return document.%1$s.%2$s(%3$s);",
flashObjectId,
functionName,
functionArgs);
}
请帮助在 Flash 中使用 webdriver 解决选择框和打字操作中的问题。
提前致谢, 戈帕尔
最佳答案
Watir-Webdriver 不支持 Flash 页面。
关于java - 在 Flash 页面中,选择框(组合框)无法使用 Webdriver 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10947080/