本文整理汇总了Java中org.sikuli.script.FindFailed类的典型用法代码示例。如果您正苦于以下问题:Java FindFailed类的具体用法?Java FindFailed怎么用?Java FindFailed使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FindFailed类属于org.sikuli.script包,在下文中一共展示了FindFailed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openMidiAutomatorInstaller
import org.sikuli.script.FindFailed; //导入依赖的package包/类
/**
* Opens the Midi Automator installer
*
* @throws IOException
* @throws FindFailed
*/
public static void openMidiAutomatorInstaller() throws IOException,
FindFailed {
String[] command = null;
if (System.getProperty("os.name").equals("Mac OS X")) {
command = new String[] { "open", "-n", "target/MIDI Automator.dmg" };
}
if (System.getProperty("os.name").contains("Windows")) {
command = new String[] { SystemUtils
.replaceSystemVariables("\"%MIDIAUTOMATORGIT%\\Midi Automator\\target\\midiautomator_setup.exe\"") };
}
SystemUtils.runShellCommand(command);
focusMidiAutomatorInstaller();
}
示例2: setImageIfUrlsIsSet
import org.sikuli.script.FindFailed; //导入依赖的package包/类
private void setImageIfUrlsIsSet(SikuliElement sikuliElement, int timeoutInSeconds) {
if (sikuliElement.getImages().length > 1) {
boolean imageFound = false;
long timeoutExpiredMs = System.currentTimeMillis() + timeoutInSeconds * 1000;
while (!imageFound) {
for (int i = 0; i < sikuliElement.getImages().length; i++) {
imageFound = sikuli.exists(new Pattern(sikuliElement.getImages()[i]).similar(sikuliElement.getSimilarity0to100()/100), 0) != null;
if (imageFound) {
sikuliElement.setImage(sikuliElement.getImages()[i]);
return;
}
}
long waitMs = timeoutExpiredMs - System.currentTimeMillis();
if (waitMs <= 0) {
break;
}
}
if (!imageFound) {
throw new RuntimeException(new FindFailed("Images not found: " + Arrays.toString(sikuliElement.getImages())));
}
}
}
示例3: getMatchesList
import org.sikuli.script.FindFailed; //导入依赖的package包/类
private List<Shape> getMatchesList() {
List<Shape> rMatches = new ArrayList<>();
try {
Iterator<?> it = getMatches();
if (it != null) {
Region sRegion = Region.create(shapes.get(0).getBounds());
while (it.hasNext()) {
Object region = it.next();
Shape rx = ((Region) region).getRect();
if (sRegion != null && sRegion.getRect().contains(rx.getBounds())) {
rMatches.add(rx);
}
}
}
} catch (FindFailed | IOException | NullPointerException ex) {
Logger.getLogger(PropertyEditor.class.getName()).log(Level.SEVERE, null, ex);
}
return rMatches;
}
示例4: clickItem
import org.sikuli.script.FindFailed; //导入依赖的package包/类
public void clickItem(String imageNameOrText, Locator locator) {
SikuliLogger.logDebug("Clicking item at Server class");
imageNameOrText = locator.updateLocatorTarget(imageNameOrText);
try {
SikuliLogger.logDebug("Clicking item: " + imageNameOrText);
if (locator.isImage()) {
Helper.getRegion().click(new Pattern(imageNameOrText).similar(locator.getSimilarityasFloat())
.targetOffset(locator.getxOffset(), locator.getyOffset()));
} else if (locator.isText()) {
Location location = new TextRecognizer().findText(imageNameOrText);
Helper.getRegion().click(new Location(location.x + (double)locator.getxOffset(),
location.y + (double)locator.getyOffset()));
}
} catch (FindFailed e) {
this.handleFindFailed(locator.isRemote(), e);
}
}
示例5: doubleClickItem
import org.sikuli.script.FindFailed; //导入依赖的package包/类
public void doubleClickItem(String imageNameOrText, Locator locator) {
SikuliLogger.logDebug("Clicking item at Server class");
imageNameOrText = locator.updateLocatorTarget(imageNameOrText);
try {
SikuliLogger.logDebug("Clicking item: " + imageNameOrText);
if (locator.isImage()) {
Helper.getRegion().doubleClick(new Pattern(imageNameOrText).similar(locator.getSimilarityasFloat())
.targetOffset(locator.getxOffset(), locator.getyOffset()));
} else if (locator.isText()) {
Location location = new TextRecognizer().findText(imageNameOrText);
Helper.getRegion().doubleClick(new Location(location.x + (double)locator.getxOffset(),
location.y + (double)locator.getyOffset()));
}
} catch (FindFailed e) {
this.handleFindFailed(locator.isRemote(), e);
}
}
示例6: rightClickItem
import org.sikuli.script.FindFailed; //导入依赖的package包/类
public void rightClickItem(String imageNameOrText, Locator locator) {
SikuliLogger.logDebug("Clicking item at Server class");
imageNameOrText = locator.updateLocatorTarget(imageNameOrText);
try {
SikuliLogger.logDebug("Clicking item: " + imageNameOrText);
if (locator.isImage()) {
Helper.getRegion().rightClick(new Pattern(imageNameOrText).similar(locator.getSimilarityasFloat())
.targetOffset(locator.getxOffset(), locator.getyOffset()));
} else if (locator.isText()) {
Location location = new TextRecognizer().findText(imageNameOrText);
Helper.getRegion().rightClick(new Location(location.x + (double)locator.getxOffset(),
location.y + (double)locator.getyOffset()));
}
} catch (FindFailed e) {
this.handleFindFailed(locator.isRemote(), e);
}
}
示例7: inputTextToField
import org.sikuli.script.FindFailed; //导入依赖的package包/类
public void inputTextToField(String text, String imageNameOrText, Locator locator) {
imageNameOrText = locator.updateLocatorTarget(imageNameOrText);
if (imageNameOrText != null) {
try {
SikuliLogger.logDebug("Clicking item: " + imageNameOrText);
if (locator.isImage()) {
Helper.getRegion().click(new Pattern(imageNameOrText).similar(locator.getSimilarityasFloat())
.targetOffset(locator.getxOffset(), locator.getyOffset()));
} else if (locator.isText()) {
Location location = new TextRecognizer().findText(imageNameOrText);
Helper.getRegion().click(new Location(location.x + (double)locator.getxOffset(),
location.y + (double)locator.getyOffset()));
}
} catch (FindFailed e) {
this.handleFindFailed(locator.isRemote(), e);
}
}
this.pasteText(text);
}
示例8: testNormalTextWaitWithNoResults
import org.sikuli.script.FindFailed; //导入依赖的package包/类
@Test(expected = FindFailed.class)
public void testNormalTextWaitWithNoResults() throws FindFailed {
Server mockServer = mock(Server.class);
TextRecognizer tr = new TextRecognizer();
try {
whenNew(Server.class).withNoArguments().thenReturn(mockServer);
doReturn("src/test/resources/testImages/focus_test_app.png").when(mockServer).captureRegionImage();
tr = new TextRecognizer();
} catch (Exception e) {
e.printStackTrace();
fail();
}
Helper.setWaitTimeout(0);
tr.waitUntilTextIsVisible("Not foundable text");
}
示例9: closeMidiAutomatorInstaller
import org.sikuli.script.FindFailed; //导入依赖的package包/类
/**
* Closes the Midi Automator installer
*
* @throws IOException
* @throws FindFailed
*/
public static void closeMidiAutomatorInstaller() throws IOException,
FindFailed {
String[] command = null;
if (System.getProperty("os.name").equals("Mac OS X")) {
command = new String[] { "diskutil", "unmountDisk",
"/Volumes/MIDI Automator" };
SystemUtils.runShellCommand(command);
}
if (System.getProperty("os.name").contains("Windows")) {
try {
closeNSISInstaller();
} catch (FindFailed e) {
cancelNSISInstaller();
}
}
}
示例10: findMidiAutomatorInstallerRegion
import org.sikuli.script.FindFailed; //导入依赖的package包/类
/**
* Finds the region of the Midi Automator installer main Window
*
* @return the found region
* @throws FindFailed
*/
public static Region findMidiAutomatorInstallerRegion() throws FindFailed {
try {
setMinSimilarity(LOW_SIMILARITY);
SikuliXAutomation.setSearchRegion(SCREEN);
Region searchRegion = findMultipleStateRegion(MAX_TIMEOUT,
"midi_automator_installer.png");
setMinSimilarity(DEFAULT_SIMILARITY);
searchRegion.y -= 41;
searchRegion.h += 41;
return searchRegion;
} catch (FindFailed e) {
System.err.println("findMidiAutomatorInstallerRegion() failed");
throw e;
}
}
示例11: openMidiAutomator
import org.sikuli.script.FindFailed; //导入依赖的package包/类
/**
* Opens the Midi Automator program
*
* @throws IOException
* @throws FindFailed
*/
public static void openMidiAutomator() throws IOException, FindFailed {
String[] command = null;
if (System.getProperty("os.name").equals("Mac OS X")) {
command = new String[] { "open", "-n",
"/Applications/Midi Automator.app" };
}
if (System.getProperty("os.name").contains("Windows")) {
command = new String[] {
SystemUtils
.replaceSystemVariables("%PROGRAMFILES%\\Midi Automator\\Midi Automator.exe"),
"-test" };
}
SystemUtils.runShellCommand(command);
focusMidiAutomator();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
示例12: findMidiAutomatorRegion
import org.sikuli.script.FindFailed; //导入依赖的package包/类
/**
* Finds the region of the Midi Automator main Window
*
* @return the found region
* @throws FindFailed
*/
public static Region findMidiAutomatorRegion() throws FindFailed {
try {
setMinSimilarity(LOW_SIMILARITY);
SikuliXAutomation.setSearchRegion(SCREEN);
Region searchRegion = findMultipleStateRegion(MAX_TIMEOUT,
"midi_automator.png");
setMinSimilarity(DEFAULT_SIMILARITY);
searchRegion.y = searchRegion.y - 21;
searchRegion.w = searchRegion.w + 500;
searchRegion.h = searchRegion.h + 100;
return searchRegion;
} catch (FindFailed e) {
System.err.println("findMidiAutomatorRegion() failed");
throw e;
}
}
示例13: checkIfFileOpened
import org.sikuli.script.FindFailed; //导入依赖的package包/类
/**
* Checks if the file opened correctly
*
* @param states
* the different states of the region
*/
public void checkIfFileOpened(String... states) {
Region match = null;
try {
// check if file opened
SikuliXAutomation.setSearchRegion(SCREEN);
match = findMultipleStateRegion(DEFAULT_TIMEOUT, states);
// close editor
match.click();
closeFocusedProgram();
} catch (FindFailed e) {
Fail.fail("File did not open.", e);
}
}
示例14: checkIfFileNotOpened
import org.sikuli.script.FindFailed; //导入依赖的package包/类
/**
* Checks if the file did not open.
*
* @param states
* the different states of the region
*/
public void checkIfFileNotOpened(String... states) {
Region match = null;
try {
// check if file opened
SikuliXAutomation.setSearchRegion(SCREEN);
match = findMultipleStateRegion(DEFAULT_TIMEOUT, states);
// close editor
match.click();
closeFocusedProgram();
Fail.fail("File did open.");
} catch (FindFailed e) {
}
}
示例15: findMultipleStateRegion
import org.sikuli.script.FindFailed; //导入依赖的package包/类
/**
* Finds a region that can have multiple states, i.e. active, inactive,
* unfocused
*
* @param timeout
* the timeout to search for every state
* @param states
* the different states of the region
* @return The found region
* @throws FindFailed
*/
public static Region findMultipleStateRegion(double timeout,
String... states) throws FindFailed {
Region match;
FindFailed findFailed = null;
for (String state : states) {
if (state != null) {
try {
match = searchRegion.wait(screenshotpath + state, timeout);
return match;
} catch (FindFailed e) {
findFailed = e;
System.out.println(state
+ " not found. Trying next state...");
}
}
}
throw findFailed;
}