List of usage examples for org.openqa.selenium WebElement click
void click();
From source file:ca.nrc.cadc.UserStorageBrowserPage.java
License:Open Source License
public void clickFolder(String folderName) { WebElement folder = (new WebDriverWait(driver, 10)).until(ExpectedConditions.elementToBeClickable( xpath("//*[@id=\"beacon\"]/tbody/tr/td/a[text()[contains(.,'" + folderName + "')]]"))); System.out.println("Folder to be clicked: " + folder.getText()); folder.click(); }
From source file:ca.nrc.cadc.UserStorageBrowserPage.java
License:Open Source License
public void createNewFolder(String foldername) throws Exception { newdropdownButton.click();//from www . j a v a 2s. c o m newFolder.click(); WebElement newfolderInput = (new WebDriverWait(driver, 10)) .until(ExpectedConditions.elementToBeClickable(By.id("fname"))); sendKeys(newfolderInput, foldername); WebElement createFolderButton = find(xpath("//button[contains(text(),\"Create Folder\")]")); createFolderButton.click(); if (isJqiMsgShowing(CONFIRMATION_MSG)) { clickButton(OK); } else { throw new Exception("Could not create folder " + foldername); } }
From source file:ca.nrc.cadc.UserStorageBrowserPage.java
License:Open Source License
public void clickEditIconForRow(int rowNum) throws Exception { WebElement editIcon = find(xpath("//span[contains(@class, 'glyphicon-edit')]")); editIcon.click(); }
From source file:ca.nrc.cadc.UserStorageBrowserPage.java
License:Open Source License
public String togglePublicAttributeForRow(int rowNum) throws Exception { String currentPermission = ""; WebElement editIcon = find(xpath("//span[contains(@class, 'glyphicon-edit')]")); editIcon.click(); WebElement permissionCheckbox = (new WebDriverWait(driver, 10)) .until(ExpectedConditions.elementToBeClickable(By.id("publicPermission"))); currentPermission = permissionCheckbox.getAttribute("checked"); click(permissionCheckbox);/*ww w . j av a 2s . c o m*/ clickButton(SAVE); // confirm folder delete if (isJqiMsgShowing(SUCCESSFUL)) { clickButton(OK); } else { throw new Exception("Permissions editing not successful for row : " + rowNum); } return currentPermission; }
From source file:ca.nrc.cadc.UserStorageBrowserPage.java
License:Open Source License
public void clickCheckboxForFolder(String folderName) throws Exception { WebElement folder = find(xpath("//*[@id=\"beacon\"]/tbody/tr/td/a[contains(text()," + folderName + ")]")); WebElement folderParent = folder.findElement(xpath("..")); WebElement folderCheckbox = folderParent.findElement(xpath("//div[contains(@class=\"select-checkbox\")]")); folderCheckbox.click(); }
From source file:ca.nrc.cadc.web.selenium.AbstractTestWebPage.java
License:Open Source License
protected void clearTextInput(final By by) throws Exception { final WebElement inputElement = waitUntil(ExpectedConditions.presenceOfElementLocated(by)); // Focus issues. hover(by);/*ww w . ja v a 2s. com*/ inputElement.click(); inputElement.clear(); }
From source file:ca.nrc.cadc.web.selenium.AbstractTestWebPage.java
License:Open Source License
protected void inputTextValue(final By by, final String value, final boolean clean, final boolean moveToInput) throws Exception { waitForElementPresent(by);/*from w w w . j a v a 2 s . com*/ final WebElement inputElement = find(by); if (moveToInput) { hover(by); inputElement.click(); } if (clean) { clearTextInput(by); } if (StringUtil.hasText(value)) { for (final char c : value.toCharArray()) { inputElement.sendKeys(Character.toString(c)); waitFor(250L); } } }
From source file:ca.nrc.cadc.web.selenium.AbstractWebApplicationIntegrationTest.java
License:Open Source License
public void click(final WebElement elem) { elem.click(); }
From source file:CartTest.CartTest.java
@Test public void addToCart() { //There are two kinds of Categories to show products. Therefore, I should consider two situations. String name;/*w ww . ja v a2s . c o m*/ WebElement addtocart = driver.findElement(By .xpath("//*[@id=\"default_products_page_container\"]/div[3]/div[2]/form/div[2]/div[1]/span/input")); if (addtocart == null) { addtocart = driver.findElement(By.xpath( "//*[@id=\"grid_view_products_page_container\"]/div[3]/div[1]/div[3]/form/div/div[1]/span/input")); name = driver .findElement( By.xpath("//*[@id=\"grid_view_products_page_container\"]/div[3]/div[1]/div[2]/h2/a")) .getText(); } else { name = driver.findElement(By.xpath("//*[@id=\"default_products_page_container\"]/div[3]/div[2]/h2/a")) .getText(); System.out.println(name); } addtocart.click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);// wait for web response driver.findElement(By.xpath("//*[@id=\"fancy_notification_content\"]/a[1]")).click();// click "go to checkout" button driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);//wait String itemName = driver .findElement(By.xpath("//*[@id=\"checkout_page_container\"]/div[1]/table/tbody/tr[2]/td[2]/a")) .getAttribute("text"); System.out.println("xxx" + itemName); String quantity = driver .findElement(By .xpath("//*[@id=\"checkout_page_container\"]/div[1]/table/tbody/tr[2]/td[3]/form/input[1]")) .getAttribute("value"); assertEquals(quantity, "1");// the quantity should be one; assertEquals(itemName, name);// the item should be what I added }
From source file:CartTest.CartTest.java
private void addItemIntoCart() { WebElement addtocart = driver.findElement(By .xpath("//*[@id=\"default_products_page_container\"]/div[3]/div[2]/form/div[2]/div[1]/span/input")); if (addtocart == null) { addtocart = driver.findElement(By.xpath( "//*[@id=\"grid_view_products_page_container\"]/div[3]/div[1]/div[3]/form/div/div[1]/span/input")); }// w ww . j ava 2s . co m addtocart.click(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);// wait for web response driver.findElement(By.xpath("//*[@id=\"fancy_notification_content\"]/a[1]")).click();// click "go to checkout" button driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);//wait }