Java 在Flash页面中,选择框(组合框)无法使用Webdriver
我已经编写了一些示例代码,在Flash页面中使用webdriver选择一个组合框,但是select(…)和type(…)方法不起作用,但是click(…)方法可以很好地工作 请帮助解决此问题。 类型1:以下方法不起作用Java 在Flash页面中,选择框(组合框)无法使用Webdriver,java,webdriver,watir-webdriver,Java,Webdriver,Watir Webdriver,我已经编写了一些示例代码,在Flash页面中使用webdriver选择一个组合框,但是select(…)和type(…)方法不起作用,但是click(…)方法可以很好地工作 请帮助解决此问题。 类型1:以下方法不起作用 public void type(String locator, String value) { ((JavascriptExecutor) webDriver).executeScript("document.getElementById('" + flashObjec
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 +"'})");
}
它在下面的点击(..)方法中工作良好
公共字符串单击(最终字符串objectId,最终字符串optionalButtonLabel)
{
返回调用(“doFlexClick”、objectId、optionalButtonLabel);
}
私有字符串调用(最终字符串functionName、最终字符串…args)
{
最终目标结果=
((JavascriptExecutor)webDriver).executeScript(
makeJsFunction(functionName,args),
新对象[0]);
返回结果!=null?result.toString():null;
}
私有字符串makeJsFunction(最终字符串functionName、最终字符串…args)
{
final StringBuffer FunctionRGS=新StringBuffer();
如果(args.length>0)
{
对于(int i=0;i0)
{
functorgs.append(“,”);
}
append(String.format(“%1$s”,args[i]);
System.out.println(“functorgs:+functorgs”);
}
}
返回字符串格式(
“返回文档。%1$s.%2$s(%3$s);”,
flashObjectId,
函数名,
函数(RGS);
}
请在选择框中帮助修复此问题,并在Flash中使用webdriver执行tyep操作
提前感谢,,
GopalWatir Webdriver不支持flash页面。感谢SCott的支持。我已经浏览了URL:并在我的本地点击(…)方法中做了相同的更改,效果很好,但没有选择框(组合框)、键入、拖放操作。
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);
}