I am newbie for flex automation , is there any possible way to integrate flex monkium wtih selenium ide to record particular test cases as we can do for any web application in selenium ide
-
no there is no such way however you can do flash automation in selenium web driver by using Sikuli in java language if you need tutorial i can share that with you – fahad Oct 21 '15 at 06:55
-
sure ! thats more appreciated – Laraib Patoli Oct 21 '15 at 07:19
-
@fahad one more question is it feasible to use this in long term, for example is this maintainable if new changes occur – Laraib Patoli Oct 21 '15 at 07:39
-
yes it is feasible to use it in long run because its image based automation – fahad Oct 21 '15 at 09:16
-
Please mark my answer as correct if its use full to you – fahad Oct 21 '15 at 09:16
1 Answers
You can also use Sikuli for automation of flash Please check this link for Flash automation Tutorial to start with basic Turtorial
Sikuli API for Java provides image-based GUI automation functionalities to Java programmers. It is created and will be actively maintained bySikuli Lab. The effort of making this API is a response to the desire of many Sikuli users to use Sikuli Script's functionalities directly in their Java programs, rather than writing Jython scripts. This new Java library has a re-designed API and includes several new functions that were not available in the original Sikuli Script, such as the abilities to match colors, handle events, and find geometric patterns such as rectangular buttons. You can also download this eclipse project from : https://drive.google.com/file/d/0B09BIsDTY_AuYVB4ZjJNM3h0ZlE/view?usp=sharing
Steps:
Open Eclipse IDE Create a new Project Download Selenium Bindings Download Sukuli JAR Right click on you project Open New>Class
Right click on you project Open Build Path>Configure Build Path Open Libraries Tab Click add External Jars button Add Following Imports import java.io.File; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; import org.openqa.selenium.NoAlertPresentException; import org.openqa.selenium.firefox.FirefoxDriver; import org.sikuli.api.*; import org.sikuli.api.robot.Mouse; import org.sikuli.api.robot.desktop.DesktopMouse; Add Selenium and Java Bindings Paste Following code in Your Class @BeforeClass public static void setUp() throws Exception { wd = new FirefoxDriver(); wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
@Test public void TestCase1() throws InterruptedException { } @After public void tearDown() { wd.quit(); } public static boolean isAlertPresent(FirefoxDriver wd) { try { wd.switchTo().alert(); return true; } catch (NoAlertPresentException e) { return false; }
}
Open Flash Calculator Link in Browser “http://www.terrence.com/flash/calculator.html “
Take small images of required number and operations like 1.png,2.png , equal.png and multiply.png etc. you can use snipping tool utility for this purpose its pre-installed in Win 7 or greater
Like These
Now Create function which takes path of image as string and click on that image
Code is:
public void click_Image(String img)
{
s = new DesktopScreenRegion();
target = new ImageTarget(new File(img));
r = s.find(target);
// Create a mouse object
mouse = new DesktopMouse();
// Use the mouse object to click on the center of the target region
mouse.click(r.getCenter());
}
Now add Following code in your test case first navigate to URL by web driver and then click by images which you created example code is
@Test
public void register() throws InterruptedException {
wd.get("http://www.terrence.com/flash/calculator.html");
click_Image("IMG\\1.png");
click_Image("IMG\\0.png");
click_Image("IMG\\plus.png");
click_Image("IMG\\2.png");
click_Image("IMG\\equal.png");
}
Your final code would be:
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.sikuli.api.*;
import org.sikuli.api.robot.Mouse;
import org.sikuli.api.robot.desktop.DesktopMouse;
public class testAutomation {
public static FirefoxDriver wd;
ScreenRegion s;
Target target ;
ScreenRegion r;
// Create a mouse object
Mouse mouse ;
public void click_Image(String img)
{
s = new DesktopScreenRegion();
target = new ImageTarget(new File(img));
r = s.find(target);
// Create a mouse object
mouse = new DesktopMouse();
// Use the mouse object to click on the center of the target region
mouse.click(r.getCenter());
}
@BeforeClass
public static void setUp() throws Exception {
wd = new FirefoxDriver();
wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
@Test
public void register() throws InterruptedException {
wd.get("http://www.terrence.com/flash/calculator.html");
click_Image("IMG\\1.png");
click_Image("IMG\\0.png");
click_Image("IMG\\plus.png");
click_Image("IMG\\2.png");
click_Image("IMG\\equal.png");
}
@After
public void tearDown() {
wd.quit();
}
public static boolean isAlertPresent(FirefoxDriver wd) {
try {
wd.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
}

- 389
- 2
- 12
-
i found this very interesting, i just wanted to confirm lets suppose in near future i wanted to do this for chrome and if some how resolution is affected, still this would be able to cater those images ? your help is really appreciated Thanks – Laraib Patoli Oct 21 '15 at 13:48
-
Link-only answers are discouraged on Stackoverflow: http://meta.stackexchange.com/questions/225370/your-answer-is-in-another-castle-when-is-an-answer-not-an-answer – Brian Oct 21 '15 at 19:01
-
sikuli works on what is shown at screen it damms care rather its chrome IE or some other broswer i tried it even on desktop apps it worked for me – fahad Oct 22 '15 at 06:09