List of usage examples for org.openqa.selenium.interactions Actions contextClick
public Actions contextClick(WebElement target)
From source file:com.raja.anucarita.SeCustomActions.java
License:Open Source License
public static void seRightClick(WebDriver driver, String locator, String replace) throws Exception { locator = values.getProperty(locator); element = SeCustomUtils.elementReturn(driver, locator); Actions action = new Actions(driver); action.contextClick(element).build().perform(); }
From source file:com.sugarcrm.candybean.automation.control.VControl.java
License:Open Source License
/** * Right-click this control.//from www. j a v a 2s . com * * @throws Exception if the element cannot be found */ public void rightClick() throws Exception { voodoo.log.info("Selenium: right-clicking control: " + this.toString()); Actions action = new Actions(this.iface.wd); action.contextClick(this.we).perform(); }
From source file:com.sugarcrm.candybean.automation.webdriver.WebDriverElement.java
License:Open Source License
/** * Right-click this element./* ww w . j a v a 2 s . co m*/ */ public void rightClick() throws CandybeanException { logger.info("Right-clicking element: " + this.toString()); Actions action = new Actions(this.wd); action.contextClick(this.we).perform(); }
From source file:com.technophobia.webdriver.substeps.impl.ActionWebDriverSubStepImplementations.java
License:Open Source License
/** * Performs a context click (typically right click, unless this has been * changed by the user) on the current element. * /*from w w w . j a v a 2 s .c om*/ * @example PerformContextClick * @section Clicks * */ @Step("PerformContextClick") public void performContextClick() { final Actions actions = new Actions(webDriver()); actions.contextClick(webDriverContext().getCurrentElement()); actions.perform(); }
From source file:com.vaadin.tests.components.tree.TreeContextMenuAndIconsTest.java
License:Apache License
private WebElement openContextMenu(WebElement element) { Actions actions = new Actions(getDriver()); // Note: on Firefox, the first menu item does not get focus; on other // browsers it does actions.contextClick(element); actions.perform();//from www . j a v a 2 s. co m return findElement(By.className("v-contextmenu")); }
From source file:imagedownload.AutoSave.java
public static void save(WebDriver driver, WebElement image, String filePath) { filePath = filePath.toLowerCase();/*www . j a va 2 s . co m*/ try { // Rihgt click on Image using contextClick() method. Actions action = new Actions(driver); action.contextClick(image).build().perform(); Thread.sleep(500); Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_SHIFT); Thread.sleep(500); char[] seq = filePath.toCharArray(); for (int i = 0; i < seq.length; i++) { Keys k = Keys.lookup(seq[i]); int[] keys = k.getKeys(); // System.out.println("Key identified: "+k.getLabel()+", "+keys); for (int j = 0; j < keys.length; j++) { robot.keyPress(keys[j]); } for (int j = keys.length - 1; j >= 0; j--) { robot.keyRelease(keys[j]); } } robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); boolean saveComplete = false; while (!saveComplete) { File f = new File(filePath); saveComplete = f.exists(); System.out.println("Save complete: " + saveComplete); Thread.sleep(100); } } catch (AWTException ex) { Logger.getLogger(Downloader.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { Logger.getLogger(AutoSave.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.auraframework.components.ui.InputTextUITest.java
License:Apache License
@ExcludeBrowsers({ BrowserType.IPAD, BrowserType.IPHONE, BrowserType.SAFARI, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET })/* ww w . ja v a 2s .com*/ public void testBaseMouseClickEventValue() throws Exception { open(TEST_CMP); WebElement input = findDomElement(By.cssSelector(".keyup2")); WebElement outputValue = findDomElement(By.cssSelector(".outputValue")); // IE < 9 uses values 1, 2, 4 for left, right, middle click (respectively) String expectedVal = (BrowserType.IE7.equals(getBrowserType()) || BrowserType.IE8.equals(getBrowserType())) ? "1" : "0"; input.click(); assertEquals("Left click not performed ", expectedVal, outputValue.getText()); // right click behavior Actions actions = new Actions(getDriver()); actions.contextClick(input).perform(); assertEquals("Right click not performed ", "2", outputValue.getText()); }
From source file:org.auraframework.integration.test.components.ui.inputText.InputTextUITest.java
License:Apache License
@ExcludeBrowsers({ BrowserType.IPAD, BrowserType.IPHONE, BrowserType.SAFARI, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET })//from ww w.j ava 2 s . c o m @Test public void testBaseMouseClickEventValue() throws Exception { open(TEST_CMP); WebElement input = findDomElement(By.cssSelector(".keyup2")); WebElement outputValue = findDomElement(By.cssSelector(".outputValue")); // IE < 9 uses values 1, 2, 4 for left, right, middle click (respectively) String expectedVal = (BrowserType.IE7.equals(getBrowserType()) || BrowserType.IE8.equals(getBrowserType())) ? "1" : "0"; input.click(); assertEquals("Left click not performed ", expectedVal, outputValue.getText()); // right click behavior Actions actions = new Actions(getDriver()); actions.contextClick(input).perform(); assertEquals("Right click not performed ", "2", outputValue.getText()); }
From source file:org.cerberus.service.engine.impl.WebDriverService.java
License:Open Source License
@Override public MessageEvent doSeleniumActionRightClick(Session session, Identifier identifier) { MessageEvent message;// w w w .ja v a 2 s . c o m try { AnswerItem answer = this.getSeleniumElement(session, identifier, true, true); if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) { WebElement webElement = (WebElement) answer.getItem(); if (webElement != null) { Actions actions = new Actions(session.getDriver()); actions.contextClick(webElement); actions.build().perform(); message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_RIGHTCLICK); message.setDescription(message.getDescription().replaceAll("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator())); return message; } } return answer.getResultMessage(); } catch (NoSuchElementException exception) { message = new MessageEvent(MessageEventEnum.ACTION_FAILED_RIGHTCLICK_NO_SUCH_ELEMENT); message.setDescription(message.getDescription().replaceAll("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator())); MyLogger.log(WebDriverService.class.getName(), Level.DEBUG, exception.toString()); return message; } catch (WebDriverException exception) { message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELENIUM_CONNECTIVITY); MyLogger.log(WebDriverService.class.getName(), Level.FATAL, exception.toString()); return message; } }
From source file:org.cerberus.service.webdriver.impl.WebDriverService.java
License:Open Source License
@Override public MessageEvent doSeleniumActionRightClick(Session session, Identifier identifier) { MessageEvent message;/*from www. j a v a 2 s . c o m*/ try { AnswerItem answer = this.getSeleniumElement(session, identifier, true, true); if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) { WebElement webElement = (WebElement) answer.getItem(); if (webElement != null) { Actions actions = new Actions(session.getDriver()); actions.contextClick(webElement); actions.build().perform(); message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_RIGHTCLICK); message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator())); return message; } } return answer.getResultMessage(); } catch (NoSuchElementException exception) { message = new MessageEvent(MessageEventEnum.ACTION_FAILED_RIGHTCLICK_NO_SUCH_ELEMENT); message.setDescription(message.getDescription().replace("%ELEMENT%", identifier.getIdentifier() + "=" + identifier.getLocator())); MyLogger.log(WebDriverService.class.getName(), Level.DEBUG, exception.toString()); return message; } catch (TimeoutException exception) { message = new MessageEvent(MessageEventEnum.ACTION_FAILED_TIMEOUT); message.setDescription(message.getDescription().replace("%TIMEOUT%", String.valueOf(session.getCerberus_selenium_wait_element()))); MyLogger.log(WebDriverService.class.getName(), Level.WARN, exception.toString()); return message; } catch (WebDriverException exception) { MyLogger.log(WebDriverService.class.getName(), Level.FATAL, exception.toString()); return parseWebDriverException(exception); } }