Flash Automation using Selenium web driver Flash Automation using Selenium web driver selenium selenium

Flash Automation using Selenium web driver


Why not trying Actions?

Create the invisible button you will click on

((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_y and result_pos_x are pixels int values

element_to_append is jquery webelement reference

Move to the button and click it (like play or pause button)

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();

And insert your code with asserts. In my case, I am able to reach some Flash player states via JS, so below is the example of my 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"));

Note that the Actions are supported in FF without adding Native events, but you need to add Native events support in Chrome.

The only disadvantage of that method is that you need to create mapping(pixels map of every flash element) for buttons.