26
Dec

Ways to Interact with Flash objects in Selenium

#1. Interact with Flash objects based on element location:

If your script can locate the x,y coordinates of an element, you can click it using selenium ACTION class as follow:

Actions Action = new Actions(driver);

WebElement e = driver.findElements(By.cssSelector(“button”)); Action.moveToElement(e).clickAndHold().perform();

Action.release().perform();

———————————————————————————————————————-

#2. Interact with objects via Javascriptexecutor

 

If your flash exposes object properties e.g. Name, ID etc.  “JavascriptExecutor” can be used to interact with elements as follow:

Step 1:  Create a custom function to perform “Click” on webelement passed as argument

public void safeJavaScriptClick(WebElement element) throws Exception {

((JavascriptExecutor) driver).executeScript(“arguments[0].click();”, element);

}

Step 2: Call above function with WebElement which supports “Click” operation:

WebElement goButton = driver.findElement(By.cssSelector(“input[value=Go]”));

CustomJavaScriptClick(goButton);

 

———————————————————————————————————————