Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Handling Native Dialogs with Sikuli
Handling Native Dialogs with Sikuli [message #664246] Thu, 07 April 2011 22:41
Felix Lu is currently offline Felix Lu
Messages: 12
Registered: April 2011
Junior Member
We're trying to use SWTBot in our testing and found that the native dialogs (open file, select directory, etc.) cannot be handled with SWTBot.

Then we found Sikuli ( http://sikuli.org/ ) and successfully loaded it with SWTBot.

Please refer to the following steps we used to test the product:
1. Create an SWTBot Test Plug-in Project.
2. Create new folder "lib" in the project and copy "sikuli-script.jar" into it.
3. Add "sikuli-script.jar" to Build Path and to Runtime Classpath.
4. Create a test class using SWTBot to open the Open File dialog, and using Sikuli to enter the file path and submit.
5. Run the test class as an SWTBot Test (Changing the tab Main to run the testing product in Run configuration).

The testing code would like this (the path should be absolute, the image "FileName.png" here contains the Label and Text Field of File name in the "Open" dialog):
package org.felix.test;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.SWTBotAssert;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Screen;

@RunWith(SWTBotJunit4ClassRunner.class)
public class CreateProject {

 private SWTWorkbenchBot bot;

 @Test
 public void openFile() throws Exception {
  bot.menu("File").menu("Open File...").click();
  Screen s = new Screen();
  try{
   s.wait("D:\\imgs\\FileName.png");
   s.type("D:\\imgs\\FileName.png", "/path/to/testfile\n", 0);
  }
  catch(FindFailed e){
   e.printStackTrace();
  }
 }

 @Before
 public void setup() {
  bot = new SWTWorkbenchBot();
 }
}
Previous Topic:Create element out of clipping window
Next Topic:[ANN] New recorder and domain-language test tool based on SWTBot
Goto Forum:
  


Current Time: Mon Sep 01 07:41:31 EDT 2014

Powered by FUDForum. Page generated in 0.02325 seconds