Added VerifyElementPresent and VerifyElementNotPresent
This commit is contained in:
@@ -167,6 +167,12 @@ public class CommandPopupMenu extends JPopupMenu {
|
|||||||
CommandMenuItem mntmSetUpdateThreshold = new CommandMenuItem("setUpdateThreshold", 2, false);
|
CommandMenuItem mntmSetUpdateThreshold = new CommandMenuItem("setUpdateThreshold", 2, false);
|
||||||
add(mntmSetUpdateThreshold);
|
add(mntmSetUpdateThreshold);
|
||||||
|
|
||||||
|
CommandMenuItem mntmVerifyElementNotPresent = new CommandMenuItem("verifyElementNotPresent", 2);
|
||||||
|
add(mntmVerifyElementNotPresent);
|
||||||
|
|
||||||
|
CommandMenuItem mntmVerifyElementPresent = new CommandMenuItem("verifyElementPresent", 2);
|
||||||
|
add(mntmVerifyElementPresent);
|
||||||
|
|
||||||
CommandMenuItem mntmWaitforclass = new CommandMenuItem("waitForClass", 2, false);
|
CommandMenuItem mntmWaitforclass = new CommandMenuItem("waitForClass", 2, false);
|
||||||
add(mntmWaitforclass);
|
add(mntmWaitforclass);
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.awt.Point;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import org.synthuse.commands.*;
|
import org.synthuse.commands.*;
|
||||||
|
|
||||||
@@ -126,7 +127,14 @@ public class CommandProcessor implements Runnable{
|
|||||||
events.statusChanged("Script Execution " + forcedStr + " with " + scriptErrorCount + " error(s) in " + new DecimalFormat("#.###").format(seconds) + " seconds");
|
events.statusChanged("Script Execution " + forcedStr + " with " + scriptErrorCount + " error(s) in " + new DecimalFormat("#.###").format(seconds) + " seconds");
|
||||||
events.executionCompleted();
|
events.executionCompleted();
|
||||||
if (scriptErrorCount > 0 && !isQuiet)
|
if (scriptErrorCount > 0 && !isQuiet)
|
||||||
JOptionPane.showMessageDialog(null, lastError);
|
{
|
||||||
|
JOptionPane optionPane = new JOptionPane(lastError);
|
||||||
|
JDialog dialog = optionPane.createDialog("Errors");
|
||||||
|
dialog.setAlwaysOnTop(SynthuseDlg.config.isAlwaysOnTop());
|
||||||
|
dialog.setVisible(true);
|
||||||
|
dialog.dispose();
|
||||||
|
//JOptionPane.showMessageDialog(null, lastError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object execute(String command, String[] args) {
|
public Object execute(String command, String[] args) {
|
||||||
@@ -251,6 +259,10 @@ public class CommandProcessor implements Runnable{
|
|||||||
return main.cmdSetTimeout(args);
|
return main.cmdSetTimeout(args);
|
||||||
if (command.equals("setUpdateThreshold"))
|
if (command.equals("setUpdateThreshold"))
|
||||||
return main.cmdSetUpdateThreshold(args);
|
return main.cmdSetUpdateThreshold(args);
|
||||||
|
if (command.equals("verifyElementNotPresent"))
|
||||||
|
return main.cmdVerifyElementNotPresent(args);
|
||||||
|
if (command.equals("verifyElementPresent"))
|
||||||
|
return main.cmdVerifyElementPresent(args);
|
||||||
if (command.equals("waitForTitle"))
|
if (command.equals("waitForTitle"))
|
||||||
return main.cmdWaitForTitle(args);
|
return main.cmdWaitForTitle(args);
|
||||||
if (command.equals("waitForText"))
|
if (command.equals("waitForText"))
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class SynthuseDlg extends JFrame {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static String VERSION_STR = "1.1.6";
|
public static String VERSION_STR = "1.1.7";
|
||||||
|
|
||||||
public static String RES_STR_MAIN_ICON = "/org/synthuse/img/gnome-robots.png";
|
public static String RES_STR_MAIN_ICON = "/org/synthuse/img/gnome-robots.png";
|
||||||
public static String RES_STR_REFRESH_IMG = "/org/synthuse/img/rapidsvn.png";
|
public static String RES_STR_REFRESH_IMG = "/org/synthuse/img/rapidsvn.png";
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class MainCommands extends BaseCommand {
|
|||||||
return false;
|
return false;
|
||||||
long totalAttempts = (long) (CommandProcessor.WAIT_TIMEOUT_THRESHOLD / (CommandProcessor.XML_UPDATE_THRESHOLD * 1000));
|
long totalAttempts = (long) (CommandProcessor.WAIT_TIMEOUT_THRESHOLD / (CommandProcessor.XML_UPDATE_THRESHOLD * 1000));
|
||||||
long attemptCount = 0;
|
long attemptCount = 0;
|
||||||
String xpath = "/EnumeratedWindows/win[@TEXT='" + WindowsEnumeratedXml.escapeXmlAttributeValue(args[0].toUpperCase()) + "']";
|
String xpath = "/EnumeratedWindows/*[@TEXT='" + WindowsEnumeratedXml.escapeXmlAttributeValue(args[0].toUpperCase()) + "']";
|
||||||
WinPtr handle = findHandleWithXpath(xpath, true);
|
WinPtr handle = findHandleWithXpath(xpath, true);
|
||||||
if (!handle.isEmpty())// first test without a timeout
|
if (!handle.isEmpty())// first test without a timeout
|
||||||
return true;
|
return true;
|
||||||
@@ -82,7 +82,9 @@ public class MainCommands extends BaseCommand {
|
|||||||
if (isProcessorStopped())
|
if (isProcessorStopped())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return handle != null;
|
if (handle.isEmpty())
|
||||||
|
appendError("Error: command '" + getCurrentCommand() + "' failed to find element matching " + args[0]);
|
||||||
|
return (!handle.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean cmdWaitForText(String[] args) {
|
public boolean cmdWaitForText(String[] args) {
|
||||||
@@ -103,7 +105,9 @@ public class MainCommands extends BaseCommand {
|
|||||||
if (isProcessorStopped())
|
if (isProcessorStopped())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return handle != null;
|
if (handle.isEmpty())
|
||||||
|
appendError("Error: command '" + getCurrentCommand() + "' failed to find element matching " + args[0]);
|
||||||
|
return (!handle.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean cmdWaitForClass(String[] args) {
|
public boolean cmdWaitForClass(String[] args) {
|
||||||
@@ -111,7 +115,7 @@ public class MainCommands extends BaseCommand {
|
|||||||
return false;
|
return false;
|
||||||
long totalAttempts = (long) (CommandProcessor.WAIT_TIMEOUT_THRESHOLD / (CommandProcessor.XML_UPDATE_THRESHOLD * 1000));
|
long totalAttempts = (long) (CommandProcessor.WAIT_TIMEOUT_THRESHOLD / (CommandProcessor.XML_UPDATE_THRESHOLD * 1000));
|
||||||
long attemptCount = 0;
|
long attemptCount = 0;
|
||||||
String xpath = "//win[@CLASS='" + WindowsEnumeratedXml.escapeXmlAttributeValue(args[0].toUpperCase()) + "']";
|
String xpath = "//[@CLASS='" + WindowsEnumeratedXml.escapeXmlAttributeValue(args[0].toUpperCase()) + "']";
|
||||||
WinPtr handle = findHandleWithXpath(xpath, true);
|
WinPtr handle = findHandleWithXpath(xpath, true);
|
||||||
if (!handle.isEmpty())// first test without a timeout
|
if (!handle.isEmpty())// first test without a timeout
|
||||||
return true;
|
return true;
|
||||||
@@ -124,7 +128,9 @@ public class MainCommands extends BaseCommand {
|
|||||||
if (isProcessorStopped())
|
if (isProcessorStopped())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return handle != null;
|
if (handle.isEmpty())
|
||||||
|
appendError("Error: command '" + getCurrentCommand() + "' failed to find element matching " + args[0]);
|
||||||
|
return (!handle.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean cmdWaitForVisible(String[] args) {
|
public boolean cmdWaitForVisible(String[] args) {
|
||||||
@@ -144,7 +150,37 @@ public class MainCommands extends BaseCommand {
|
|||||||
if (isProcessorStopped())
|
if (isProcessorStopped())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return handle != null;
|
if (handle.isEmpty())
|
||||||
|
appendError("Error: command '" + getCurrentCommand() + "' failed to find element matching " + args[0]);
|
||||||
|
return (!handle.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean cmdVerifyElementNotPresent(String[] args)
|
||||||
|
{
|
||||||
|
if (!checkArgumentLength(args, 1))
|
||||||
|
return false;
|
||||||
|
WinPtr handle = findHandleWithXpath(args[0], true);
|
||||||
|
if (!handle.isEmpty())
|
||||||
|
{
|
||||||
|
appendError("Error: command '" + getCurrentCommand() + "' failed to NOT find element matching " + args[0]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean cmdVerifyElementPresent(String[] args)
|
||||||
|
{
|
||||||
|
if (!checkArgumentLength(args, 1))
|
||||||
|
return false;
|
||||||
|
WinPtr handle = findHandleWithXpath(args[0], true);
|
||||||
|
if (!handle.isEmpty())
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
appendError("Error: command '" + getCurrentCommand() + "' failed to find element matching " + args[0]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user