List of usage examples for org.openqa.selenium WebElement click
void click();
From source file:com.cengage.mindtap.keywords.youSeeUPageActions.java
private void insertDataInMatrix() { int j = 1, k = 1; WebElement textBoxLocator, textBoxPoints; for (int i = 0; i < 3; i++) { while (j < 5) { textBoxLocator = driver//from w w w .j a v a 2s . c o m .findElement(By.xpath("//textarea[@id='casestudy_designerbundle_rubric_type_rows_" + i + "_cells_" + j + "_description']")); textBoxLocator.click(); textBoxLocator.clear(); textBoxLocator.sendKeys("automation :" + i + j); j += 1; } while (k < 5) { textBoxPoints = driver .findElement(By.xpath("//input[@id='casestudy_designerbundle_rubric_type_rows_" + i + "_cells_" + k + "_points']")); textBoxPoints.click(); textBoxPoints.clear(); textBoxPoints.sendKeys("10"); k += 1; } j = 0; k = 1; } }
From source file:com.cengage.mindtap.keywords.youSeeUPageActions.java
private void selectAssignmentForLPN(String name) { deselectFrame();/*from ww w . j a v a 2 s. c om*/ waitForSpinnerToDisappear(); switchToToActivityIFrame(); WebElement activity = driver.findElement( By.xpath("//a[contains(.,'" + name + "')]/parent::*/parent::*//span[contains(@class,'jq-radio')]")); activity.click(); clickOnElementUsingActionBuilder(driver.findElement(By.xpath("//input[@value='Continue']"))); deselectFrame(); }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void check(String locator) { WebElement e = findElement(locator); if (!e.isSelected()) { e.click(); }//from w w w .j av a 2 s . c o m }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void clickUsingJavascript(String locator) { WebElement we = findClickableElement(locator); String event = "arguments[0].click()"; JavascriptExecutor executor = (JavascriptExecutor) webDriver; try {/*w ww . ja v a 2 s. c o m*/ we.click(); } catch (Exception e) { executor.executeScript(event, we); } }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
/** * This method uses the webDriver object to drag and drop the elements from source to destination using javascript * * @param locator//from ww w.j a v a 2 s. c om */ @Override public void dragAndDropAnElementUsingJavascript(String sourceElement, String destinationElement, int timeoutInSeconds) { Actions builder = new Actions(getWebDriver()); WebElement src = findElement(sourceElement, timeoutInSeconds); WebElement des = findElement(destinationElement, timeoutInSeconds); String xto = Integer.toString(src.getLocation().x); String yto = Integer.toString(des.getLocation().y); JavascriptExecutor executor = (JavascriptExecutor) webDriver; String event = "function simulate(f,c,d,e){var b,a=null;for(b in eventMatchers)if(eventMatchers[b].test(c)){a=b;break}if(!a)return!1;document.createEvent?(b=document.createEvent(a),a==\"HTMLEvents\"?b.initEvent(c,!0,!0):b.initMouseEvent(c,!0,!0,document.defaultView,0,d,e,d,e,!1,!1,!1,!1,0,null),f.dispatchEvent(b)):(a=document.createEventObject(),a.detail=0,a.screenX=d,a.screenY=e,a.clientX=d,a.clientY=e,a.ctrlKey=!1,a.altKey=!1,a.shiftKey=!1,a.metaKey=!1,a.button=1,f.fireEvent(\"on\"+c,a));return!0} var eventMatchers={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/}; " + "simulate(arguments[0],\"mousedown\",0,0); simulate(arguments[0],\"mousemove\",arguments[1],arguments[2]); simulate(arguments[0],\"mouseup\",arguments[1],arguments[2]); "; try { src.click(); des.click(); builder.dragAndDrop(src, des); } catch (Exception e) { executor.executeScript(event, src, xto, yto); } }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void select(String selectLocator, String optionLocator) { Select select = new Select(findElement(selectLocator)); List<WebElement> options = select.getOptions(); log.debug("options found " + options.size() + " elements"); String[] locator = optionLocator.split("="); log.debug("Locator has " + locator.length + " elements"); String find;/*from w w w .ja va2 s . co m*/ if (locator.length > 1) { find = locator[1]; } else { find = locator[0]; } log.debug(" find is " + find); if (locator[0].contains(VALUE)) { log.debug("checking value"); for (WebElement we : options) { log.debug("Printing found options: " + we.getAttribute(VALUE)); if (we.getAttribute(VALUE).equals(find)) { we.click(); break; } } } else if (locator[0].contains("id")) { log.debug("checking id"); for (WebElement we : options) { log.debug("Printing found options: " + we.getAttribute("id")); if (we.getAttribute("id").equals(find)) { we.click(); break; } } } else if (locator[0].contains("index")) { log.debug("checking index"); for (WebElement we : options) { log.debug("Printing found options: " + we.getAttribute("index")); if (we.getAttribute("index").equals(find)) { we.click(); break; } } } else { boolean flag = false; log.debug("checking text or label, default option"); for (WebElement we : options) { log.debug("Printing found options: " + we.getText()); if (we.getText().equals(find)) { we.click(); flag = true; break; } } if (flag == false) { click(optionLocator); } } }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void type(String locator, String value) { WebElement we = findElement(locator); try {//from w w w . ja v a2 s.co m we.click(); } catch (Exception e) { } we.clear(); we.sendKeys(value); }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void typeWithoutClearing(String locator, String value) { WebElement we = findElement(locator); // try to click otherwise ignore if it fails try {/*from w w w. jav a 2 s.co m*/ we.click(); } catch (Exception e) { } we.sendKeys(value); }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void typeUsingRobot(String locator, String value) { WebElement we = findElement(locator); // try to click otherwise ignore if it fails try {//from ww w . java 2 s . c o m 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.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void uncheck(String locator) { WebElement e = findElement(locator); if (e.isSelected()) { e.click(); }/*from w w w . j av a 2 s. c o m*/ }