Example usage for java.awt AWTException printStackTrace

List of usage examples for java.awt AWTException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:faa.cucumber.pages.FaaHomePage.java

public void switchFaaBrowserTabs() {
    waitABit(2000);/*from   w w  w  .  j  a v a  2s  . co  m*/
    Robot robot;
    try {

        //         //Navigate from Left to Right
        //         Actions action= new Actions(driver);
        //         action.keyDown(Keys.CONTROL).sendKeys(Keys.TAB).build().perform();

        robot = new Robot();
        System.out.println("Switching Tabs");
        robot.keyPress(java.awt.event.KeyEvent.VK_CONTROL);
        System.out.println("Control Key Pressed");
        waitABit(1000);
        robot.keyPress(java.awt.event.KeyEvent.VK_TAB);
        System.out.println("TAB Key Pressed");
        robot.keyRelease(java.awt.event.KeyEvent.VK_TAB);
        System.out.println("TAB Key Released");
        robot.keyRelease(java.awt.event.KeyEvent.VK_CONTROL);
        System.out.println("Control Key Released");

        //         robot.keyPress(java.awt.event.KeyEvent.VK_TAB);   
        //         waitABit(1000);
        //         System.out.println("TAB Key Pressed..Second Time" );
        //         robot.keyPress(java.awt.event.KeyEvent.VK_TAB);   
        //         System.out.println("TAB Key Pressed..third Time" );
        //         waitABit(1000);

        //         System.out.println("Switching Tabs Again" );
        //         robot.keyPress(java.awt.event.KeyEvent.VK_CONTROL);
        //         System.out.println("Control Key Pressed" );
        //         waitABit(1000);
        //         robot.keyPress(java.awt.event.KeyEvent.VK_TAB);   
        //         System.out.println("TAB Key Pressed" );
        //         waitABit(1000);
        //         robot.keyRelease(java.awt.event.KeyEvent.VK_CONTROL);
        //         System.out.println("Control Key Released" );
        //         robot.keyRelease(java.awt.event.KeyEvent.VK_TAB);   
        //         System.out.println("TAB Key Released" );
        //         
        //         
        //         //Navigate from Left to Right
        //         Actions action= new Actions(driver);
        //         action.keyDown(Keys.CONTROL).sendKeys(Keys.TAB).build().perform();

        //
        //         System.out.println("Switching Tabs" );
        //         robot.keyPress(java.awt.event.KeyEvent.VK_CONTROL);
        //         System.out.println("Control Key Pressed 2" );
        //         robot.keyPress(java.awt.event.KeyEvent.VK_TAB);   
        //         System.out.println("TAB Key Pressed2 " );
        //         robot.keyRelease(java.awt.event.KeyEvent.VK_CONTROL);
        //         System.out.println("Control Key Released 2" );
        //         robot.keyRelease(java.awt.event.KeyEvent.VK_TAB);   
        //         System.out.println("TAB Key Released 2" );

        //         robot.keyPress(java.awt.event.KeyEvent.VK_CONTROL);
        //         System.out.println("Control Key Pressed" );
        //         robot.keyPress(java.awt.event.KeyEvent.VK_W);
        //         System.out.println("W Key Pressed" );
        //         robot.keyRelease(java.awt.event.KeyEvent.VK_CONTROL);
        //         System.out.println("Control Key Released" );
        //         robot.keyRelease(java.awt.event.KeyEvent.VK_W);   
        //         System.out.println("W Key Released" );
    } catch (AWTException e) {
        System.out.println("Error has occured when attempting to Switch Browser Tabs!!");
        e.printStackTrace();
    }
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

@Override
public void typeUsingRobot(String locator, String value) {
    WebElement we = findElement(locator);
    // try to click otherwise ignore if it fails
    try {/*w  w w.  j ava  2s . c om*/
        we.click();
    } catch (Exception e) {
    }
    ClipboardOwner clipboardOwner = new ClipboardOwner() {
        @Override
        public void lostOwnership(Clipboard clipboard, Transferable contents) {
        }
    };
    Robot robot;
    try {
        robot = new Robot();
        try {
            we.sendKeys(value);
        } catch (Exception e) {
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            StringSelection stringSelection = new StringSelection(value);
            clipboard.setContents(stringSelection, clipboardOwner);
            robot.keyPress(KeyEvent.VK_CONTROL);
            robot.keyPress(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_CONTROL);
        }
    } catch (AWTException e1) {
        e1.printStackTrace();
    }
}

From source file:com.virtusa.isq.rft.runtime.RFTCommandBase.java

/**
 * Performs a Java robot click on the specific coordinates. <br>
 * /*from   w  w  w.  j  a  v  a  2 s . co m*/
 * @param resolution
 *            the resolution
 * @param coordinates
 *            the coordinates
 * @param waitTime
 *            the wait time
 * @throws Exception
 *             the exception
 */
@Override
public final void mouseMoveAndClick(final String resolution, final String coordinates, final String waitTime) {

    String res = resolution;
    final int f11KeyCode = KeyEvent.VK_F11;
    final int optimumPauseBetweenkeyCombs = 10;
    String[] resArr = res.split(",");
    String[] coordinatesArr = coordinates.split(",");

    float screenWidht = Float.parseFloat(resArr[0]);
    float screeHigt = Float.parseFloat(resArr[1]);
    float xCordinate = Float.parseFloat(coordinatesArr[0]);
    float yCordinate = Float.parseFloat(coordinatesArr[1]);
    String command = "";

    if (coordinatesArr.length > 2) {

        command = coordinatesArr[2];
    }

    Robot robot = null;
    try {
        robot = new Robot();
    } catch (AWTException e) {
        e.printStackTrace();
    }

    Utils.pause(Integer.parseInt(waitTime));

    int xCordinateAutual = (int) calWidth(screenWidht, xCordinate);
    int yCordinateAutual = (int) calHight(screeHigt, yCordinate);

    robot.keyPress(f11KeyCode);
    robot.delay(optimumPauseBetweenkeyCombs);
    robot.keyRelease(f11KeyCode);
    Utils.pause(retryInterval);

    // Mouse Move
    robot.mouseMove(xCordinateAutual, yCordinateAutual);

    // Click
    if ("".equals(command)) {

        robot.mousePress(InputEvent.BUTTON1_MASK);
        Utils.pause(retryInterval);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

        reportResults(ReportLogger.ReportLevel.SUCCESS, "Mouse Move And Click", "Success",
                "Resolution : " + res);

    } else if ("dclick".equals(command.toLowerCase(Locale.getDefault()))) {

        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        final int optimumPauseBetweenDclick = 500;
        robot.delay(optimumPauseBetweenDclick);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

        reportResults(true, ReportLogger.ReportLevel.SUCCESS, "Mouse Move And Click", "Success",
                "Resolution : " + res);

    }

    robot.keyPress(f11KeyCode);
    robot.delay(optimumPauseBetweenkeyCombs);
    robot.keyRelease(f11KeyCode);
}