使用Selenium Web Driver进行Flash自动化

4
我们正在尝试使用Selenium Web Driver自动化一个具有Flex功能的Web应用程序。但是我们遇到了瓶颈,因为我们发现需要依赖第三方扩展来完成这项工作。
我们探索了几个选项,例如:
1.机器人框架
2.sfapi
但是我们发现一个问题:使用doFlexDragTo(id:String, pos:String)进行拖放操作无法正常工作。 http://code.google.com/p/sfapi/issues/detail?id=7 实际上,我们需要此功能在我们的应用程序中正常工作。
3.现在,我们考虑探索以下内容(我认为两者都是相同的) https://www.gorillalogic.com/monkeytalk/legacy-products 和FlexMonkium
如果除上述选项外还有更好的选择,请给我们建议。如果有人已经研究过此事或知道如何使用Selenium Web Driver处理基于Flex的自动化,请提供建议。
2个回答

4
尝试使用Sikuli。它应该适用于你的情况。

1
还有一个扩展可以在WebDriver上使用:http://code.google.com/p/sikuli-api/wiki/SikuliWebDriver。虽然我从未使用过它。 - aimbire

-1

为什么不尝试使用Actions?

创建一个你将要点击的不可见按钮

((JavascriptExecutor) driver).executeScript("var mybutton = $('<button/>', {id: 'invisbutton', class: 'invisbutton',text: '', style: 'position:absolute; width:20px; height:20px;top:" + result_pos_y + "px;left:" + result_pos_x + "px;visibility:hidden'}); $('" + element_to_append + "').append(mybutton);");

result_pos_yresult_pos_x 是像素整数值

element_to_append 是 jQuery 网页元素引用

移动到按钮并点击它(就像播放或暂停按钮)

Actions builder = new Actions(driver.getWebDriver());
        builder.moveToElement(driver.findElement(By.xpath("//button[@id='invisbutton']"))).build().perform();
        builder.moveToElement(driver.findElement(By.xpath("//button[@id='invisbutton']"))).click().build().perform();

并使用断言插入您的代码。在我的情况下,我能够通过JS达到某些Flash播放器状态,因此以下是我的assert示例

String brightcove_id = driver.findElement(By.xpath("//div[@id='bcplayer-container']//object")).getAttribute("id");
    ((JavascriptExecutor) driver).executeScript("brightcove.api.getExperience('" + brightcove_id + "').getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER).getIsPlaying( function(isPlaying) { alert(isPlaying)})");
    driver.pause(200);
    String alert_text = driver.switchTo().alert().getText();
    driver.switchTo().alert().accept();
    assertTrue("Video is not stopped after clicking pause button", alert_text.equals("false"));

请注意,在FF中支持Actions而无需添加Native事件,但您需要在Chrome中添加Native事件支持。
该方法的唯一缺点是您需要为按钮创建映射(每个Flash元素的像素映射)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接