Example usage for java.awt AWTException getMessage

List of usage examples for java.awt AWTException getMessage

Introduction

In this page you can find the example usage for java.awt AWTException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * Left clic at coordinates on desktop. Coordinates are from screen point of view
 * @param x//from w ww.j  ava2s . c om
 * @param y
 */
public static void leftClicOnDesktopAt(int x, int y, DriverMode driverMode,
        SeleniumGridConnector gridConnector) {

    if (driverMode == DriverMode.LOCAL) {
        try {
            Robot robot = new Robot();
            moveMouse(robot, x, y);
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        } catch (AWTException e) {
            throw new ScenarioException("leftClicOnDesktopAt: problem using Robot: " + e.getMessage());
        }
    } else if (driverMode == DriverMode.GRID && gridConnector != null) {
        gridConnector.leftClic(x, y);
    } else {
        throw new ScenarioException("driver supports leftClicOnDesktopAt only in local and grid mode");
    }
}

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * right clic at coordinates on desktop. Coordinates are from screen point of view
 * @param x//from  w w w.  j a  v a 2s. c  o m
 * @param y
 */
public static void rightClicOnDesktopAt(int x, int y, DriverMode driverMode,
        SeleniumGridConnector gridConnector) {

    if (driverMode == DriverMode.LOCAL) {
        try {
            Robot robot = new Robot();
            moveMouse(robot, x, y);
            robot.mousePress(InputEvent.BUTTON2_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK);
        } catch (AWTException e) {
            throw new ScenarioException("rightClicOnDesktopAt: problem using Robot: " + e.getMessage());
        }
    } else if (driverMode == DriverMode.GRID && gridConnector != null) {
        gridConnector.rightClic(x, y);
    } else {
        throw new ScenarioException("driver supports sendKeysToDesktop only in local and grid mode");
    }
}

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * send keys to desktop//from  w w w  .j a v a2s.  c om
 * This is useful for typing special keys like ENTER
 * @param keys
 */
public static void sendKeysToDesktop(List<Integer> keyCodes, DriverMode driverMode,
        SeleniumGridConnector gridConnector) {
    if (driverMode == DriverMode.LOCAL) {
        try {
            Robot robot = new Robot();

            WaitHelper.waitForSeconds(1);

            for (Integer key : keyCodes) {
                robot.keyPress(key);
                robot.keyRelease(key);
            }
        } catch (AWTException e) {
            throw new ScenarioException("could not initialize robot to type keys: " + e.getMessage());
        }
    } else if (driverMode == DriverMode.GRID && gridConnector != null) {
        gridConnector.sendKeysWithKeyboard(keyCodes);
    } else {
        throw new ScenarioException("driver supports sendKeysToDesktop only in local and grid mode");
    }
}

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * Left clic at coordinates on desktop. Coordinates are from screen point of view
 * @param x//from   www .  j a  va2s . co m
 * @param y
 */
public static void doubleClickOnDesktopAt(int x, int y, DriverMode driverMode,
        SeleniumGridConnector gridConnector) {

    if (driverMode == DriverMode.LOCAL) {
        try {
            Robot robot = new Robot();
            moveMouse(robot, x, y);
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
            robot.delay(10);
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        } catch (AWTException e) {
            throw new ScenarioException("doubleClickOnDesktopAt: problem using Robot: " + e.getMessage());
        }
    } else if (driverMode == DriverMode.GRID && gridConnector != null) {
        gridConnector.doubleClick(x, y);
    } else {
        throw new ScenarioException("driver supports doubleClickOnDesktopAt only in local and grid mode");
    }
}

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * Use copy to clipboard and copy-paste keyboard shortcut to write something on upload window
 *///w w w.  j ava  2s . c o m
public static void uploadFileUsingClipboard(File tempFile) {

    // Copy to clipboard
    Toolkit.getDefaultToolkit().getSystemClipboard()
            .setContents(new StringSelection(tempFile.getAbsolutePath()), null);
    Robot robot;
    try {
        robot = new Robot();

        WaitHelper.waitForSeconds(1);

        //         // Press Enter
        //         robot.keyPress(KeyEvent.VK_ENTER);
        //   
        //         // Release Enter
        //         robot.keyRelease(KeyEvent.VK_ENTER);

        // Press CTRL+V
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_V);

        // Release CTRL+V
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyRelease(KeyEvent.VK_V);
        WaitHelper.waitForSeconds(1);

        // Press Enter
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
    } catch (AWTException e) {
        throw new ScenarioException("could not initialize robot to upload file: " + e.getMessage());
    }
}

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * Upload file typing file path directly
 * @param tempFile//ww  w  . j av a 2 s.  c o  m
 */
public static void uploadFileUsingKeyboardTyping(File tempFile) {
    try {
        Keyboard keyboard = new Keyboard();
        Robot robot = keyboard.getRobot();

        WaitHelper.waitForSeconds(1);

        //         // Press Enter
        //         robot.keyPress(KeyEvent.VK_ENTER);
        //   
        //         // Release Enter
        //         robot.keyRelease(KeyEvent.VK_ENTER);

        keyboard.typeKeys(tempFile.getAbsolutePath());

        WaitHelper.waitForSeconds(1);

        // Press Enter
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);

    } catch (AWTException e) {
        throw new ScenarioException("could not initialize robot to upload file typing keys: " + e.getMessage());
    }
}

From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java

/**
 * write text to desktop./*from w  w  w. jav a 2  s  .  c o  m*/
 * @param textToWrite   text to write
 * @return
 */
public static void writeToDesktop(String textToWrite, DriverMode driverMode,
        SeleniumGridConnector gridConnector) {
    if (driverMode == DriverMode.LOCAL) {

        try {
            Keyboard keyboard = new Keyboard();
            keyboard.typeKeys(textToWrite);
        } catch (AWTException e) {
            throw new ScenarioException(
                    "writeToDesktop: could not initialize robot to type keys: " + e.getMessage());
        }
    } else if (driverMode == DriverMode.GRID && gridConnector != null) {
        gridConnector.writeText(textToWrite);
    } else {
        throw new ScenarioException("driver supports sendKeysToDesktop only in local and grid mode");
    }
}

From source file:com.hp.test.framework.jelly.ClickOKonWinDialogTag.java

@Override
public void doTag(XMLOutput arg0) throws MissingAttributeException {
    logger.info("Started Execution of ClickOkonWinDialogTag");
    WebDriver driver = getSelenium();/*from w  w  w. java 2 s . c  om*/

    try {
        Robot robot = new Robot();

        //Pressky Enter/OK Button
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);

    } catch (AWTException e) {
        logger.error("Exception in the Click OK in Windows dialog" + "\n" + e.getMessage());
    }

    logger.info("Completed Execution of ClickOkonWinDialogTag");
}

From source file:com.hp.test.framework.jelly.SelectSaveandOKonDownloadDialogTag.java

@Override
public void doTag(XMLOutput arg0) throws MissingAttributeException {
    logger.info("Started Execution of SelectSaveandOKonDownloadDialogTag");
    WebDriver driver = getSelenium();//www  . j a v a2  s  .c  o  m

    try {
        Robot robot = new Robot();

        //Pressky ALT+S
        robot.keyPress(KeyEvent.VK_ALT);
        robot.keyPress(KeyEvent.VK_S);

        //Release ALT
        robot.keyRelease(KeyEvent.VK_ALT);

        //Press Enter
        robot.keyPress(KeyEvent.VK_ENTER);

        //Release Enter
        robot.keyRelease(KeyEvent.VK_ENTER);

    } catch (AWTException e) {
        logger.error("Exception in the Save and Ok on Download dialog" + "\n" + e.getMessage());
    }

    logger.info("Completed Execution of SelectSaveandOKonDownloadDialogTag");
}

From source file:com.sec.ose.osi.ui.frm.tray.JTrayIconApp.java

private void initTray() {
    Image image = new ImageIcon(WindowUtil.class.getResource("icon.png")).getImage();

    mTrayIcon = new TrayIcon(image, mTrayTitle, createPopupMenu(BEFORE_LOGIN_STATE));
    mTrayIcon.setImageAutoSize(true);/*from  w  w w .ja va2 s .  c  o  m*/
    mTrayIcon.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mousePressed(java.awt.event.MouseEvent e) {
            log.debug("mousePressed()");
            int state = 0;
            currentFrame = UISharedData.getInstance().getCurrentFrame();

            if (currentFrame == null)
                return;
            if (currentFrame.getClass().equals(JFrmLogin.class)) {
                state = BEFORE_LOGIN_STATE;
            } else {
                state = AFTER_LOGIN_STATE;
            }

            if (SwingUtilities.isRightMouseButton(e)) {
                mTrayIcon.setPopupMenu(createPopupMenu(state));
            }

            if (e.getClickCount() >= DOUBLE_CLICK && !e.isConsumed()) {
                currentFrame.setVisible(true);
            }
        }
    });

    try {
        mSystemTray.add(mTrayIcon);
    } catch (AWTException e1) {
        log.warn(e1.getMessage());
    }
}