List of usage examples for org.openqa.selenium WebElement click
void click();
From source file:com.continuuity.test.pagetest.CreateImagetypeTest.java
License:Apache License
@Test public void test_01_submitCentOs6() throws Exception { globalDriver.get(Constants.IMAGETYPE_CREATE_URI); ImageType imageType = EXAMPLE_READER.getImageTypes(Constants.IMAGETYPES_PATH).get("centos6"); WebElement inputName = globalDriver.findElement(By.cssSelector("#inputName")); inputName.sendKeys(imageType.getName()); WebElement inputDescription = globalDriver.findElement(By.cssSelector("#inputDescription")); inputDescription.sendKeys(imageType.getDescription()); WebElement addProvider = globalDriver.findElement(By.cssSelector("#add-provider")); addProvider.click(); List<WebElement> providerEntries = globalDriver.findElements(By.cssSelector(".provider-entry")); providerEntries.get(0).findElement(By.cssSelector("select")).sendKeys("joyent"); providerEntries.get(0).findElement(By.cssSelector("input")) .sendKeys(imageType.getProviderMap().get("joyent").get("image")); providerEntries.get(1).findElement(By.cssSelector("select")).sendKeys("rackspace"); providerEntries.get(1).findElement(By.cssSelector("input")) .sendKeys(imageType.getProviderMap().get("rackspace").get("image")); globalDriver.findElement(By.cssSelector("#create-imagetype-form")).submit(); Global.driverWait(1);//from w w w.j a v a2s. c o m assertEquals(Constants.IMAGETYPES_URL, globalDriver.getCurrentUrl()); }
From source file:com.continuuity.test.pagetest.CreateServiceTest.java
License:Apache License
@Test public void test_01_submitHadoopHdfsDatanode() throws Exception { globalDriver.get(Constants.SERVICE_CREATE_URI); Service service = EXAMPLE_READER.getServices(Constants.SERVICES_PATH).get("hadoop-hdfs-datanode"); WebElement inputName = globalDriver.findElement(By.name("inputName")); inputName.sendKeys(service.getName()); WebElement inputDescription = globalDriver.findElement(By.cssSelector("#inputDescription")); inputDescription.sendKeys(service.getDescription()); Select dependsOn = new Select(globalDriver.findElement(By.cssSelector("#inputRuntimeRequires"))); WebElement addService = globalDriver.findElement(By.cssSelector("#add-service")); dependsOn.selectByVisibleText("base"); addService.click(); dependsOn.selectByVisibleText("hadoop-hdfs-namenode"); addService.click();/* w ww .j a va2s .co m*/ WebElement addAction = globalDriver.findElement(By.cssSelector("#add-action")); addAction.click(); addAction.click(); addAction.click(); addAction.click(); List<WebElement> actionEntries = globalDriver.findElements(By.cssSelector(".action-entry")); actionEntries.get(0).findElement(By.cssSelector(".inputCategory")).sendKeys("install"); actionEntries.get(0).findElement(By.cssSelector(".inputType")).sendKeys("chef-solo"); actionEntries.get(0).findElement(By.name("run_list")).sendKeys( service.getProvisionerActions().get(ProvisionerAction.INSTALL).getFields().get("run_list")); String data = service.getProvisionerActions().get(ProvisionerAction.INSTALL).getFields() .get("json_attributes"); if (data != null) { actionEntries.get(0).findElement(By.name("json_attributes")).sendKeys(data); } actionEntries.get(1).findElement(By.cssSelector(".inputCategory")).sendKeys("configure"); actionEntries.get(1).findElement(By.cssSelector(".inputType")).sendKeys("chef-solo"); actionEntries.get(1).findElement(By.name("run_list")).sendKeys( service.getProvisionerActions().get(ProvisionerAction.CONFIGURE).getFields().get("run_list")); data = service.getProvisionerActions().get(ProvisionerAction.CONFIGURE).getFields().get("json_attributes"); if (data != null) { actionEntries.get(1).findElement(By.name("json_attributes")).sendKeys(data); } actionEntries.get(2).findElement(By.cssSelector(".inputCategory")).sendKeys("start"); actionEntries.get(2).findElement(By.cssSelector(".inputType")).sendKeys("chef-solo"); actionEntries.get(2).findElement(By.name("run_list")) .sendKeys(service.getProvisionerActions().get(ProvisionerAction.START).getFields().get("run_list")); data = service.getProvisionerActions().get(ProvisionerAction.START).getFields().get("json_attributes"); if (data != null) { actionEntries.get(2).findElement(By.name("json_attributes")).sendKeys(data); } actionEntries.get(3).findElement(By.cssSelector(".inputCategory")).sendKeys("stop"); actionEntries.get(3).findElement(By.cssSelector(".inputType")).sendKeys("chef-solo"); actionEntries.get(3).findElement(By.name("run_list")) .sendKeys(service.getProvisionerActions().get(ProvisionerAction.STOP).getFields().get("run_list")); data = service.getProvisionerActions().get(ProvisionerAction.STOP).getFields().get("json_attributes"); if (data != null) { actionEntries.get(3).findElement(By.name("json_attributes")).sendKeys(data); } globalDriver.findElement(By.cssSelector("#create-service-form")).submit(); Global.driverWait(1); assertEquals(Constants.SERVICES_URL, globalDriver.getCurrentUrl()); }
From source file:com.conwet.silbops.EndToEndHTMLIT.java
License:Open Source License
@Test public void shouldCloseConnection() { System.out.println("start close connection test..."); shouldOpenConnection();// w w w .j av a 2 s . co m cleanTextArea("messageTextArea"); System.out.println("selecting endpoints to close..."); // iterates through options and close endPoints WebElement disconnect = browser.findElement(By.id("disconnectButton")); List<String> endpointList = new ArrayList<>(); for (WebElement option : browser.findElements(By.cssSelector("option[id*=\"#\"]"))) { System.out.println("disconnecting " + option.getText()); endpointList.add(option.getAttribute("id")); disconnect.click(); } System.out.println("done."); System.out.print("waiting disconnect message..."); waitMessage("messageTextArea", "disconnected"); String msg = getTextAreaValue("messageTextArea"); for (String endpoint : endpointList) { assertThat(msg).contains(endpoint); } System.out.println("done."); System.out.println("end close connection test"); }
From source file:com.daarons.transfer.DownloadTask.java
License:Apache License
private void acceptToS() { try {//from w ww .j a v a2 s . c o m WebElement acceptButton = smallWait .until(ExpectedConditions.presenceOfElementLocated(By.className("transfer__button"))); acceptButton.click(); } catch (Exception ex) { log.error("Couldn't accept ToS", ex); } }
From source file:com.daarons.transfer.DownloadTask.java
License:Apache License
private void enterPassword(String password) { WebElement passwordInput = driver.findElement( By.cssSelector("body > div > div > div.transfer > div > div.transfer__contents > div > input")); passwordInput.sendKeys(password);/*from w w w .j a va 2 s . c o m*/ WebElement enterPasswordBtn = driver.findElement(By.className("transfer__button")); enterPasswordBtn.click(); }
From source file:com.daarons.transfer.DownloadTask.java
License:Apache License
private void clickDownloadButton() { WebElement downloadButton = smallWait .until(ExpectedConditions.presenceOfElementLocated(By.className("transfer__button"))); downloadButton.click(); }
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
@Override protected Object call() throws Exception { initUploadTask();// w w w. jav a 2s . c o m acceptToS(); //put before login? String emailAddress = getTransferSettingsController().getEmailAddress(); String password = getTransferSettingsController().getPassword(); boolean loggedIn = false; if (!emailAddress.isEmpty() && !password.isEmpty()) { loggedIn = logIn(emailAddress, password); } Iterator<UploadTransferObject> i = uploadList.iterator(); while (i.hasNext()) { UploadTransferObject uploadTransferObject = i.next(); clickButtonToChooseEmailOrLink(); Message message = uploadTransferObject.getMessage(); boolean sendingEmail = false; boolean gettingLink = false; if (message != null) { clickEmailButton(); inputMessage(message); sendingEmail = true; } else { clickLinkButton(); gettingLink = true; } String uploadPassword = uploadTransferObject.getPassword(); if (uploadPassword != null && loggedIn) { enterUploadPassword(uploadPassword); } clickButtonToChooseEmailOrLink(); inputFilePath(uploadTransferObject.getUrl()); clickTransferButtonWithText("Transfer"); String downloadLink = null; int timeWaited = 0; boolean isUploadTimeAvailable = isUploadTimeAvailable(longWait); boolean isLinkAvailable = false; boolean isEmailSent = false; if (!isUploadTimeAvailable) { //check if the upload if finished. Maybe it was a small file and uploaded quickly. if (sendingEmail) { isEmailSent = isTransferButtonWithTextAvailable("Send another?", longWait); } else if (gettingLink) { isLinkAvailable = isLinkAvailable(smallWait); } //if upload isn't finished if (!isEmailSent && !isLinkAvailable) { //look for upload time again isUploadTimeAvailable = isUploadTimeAvailable(longWait); if (!isUploadTimeAvailable) { log.error("Couldn't upload this file. Continuing to next file."); TransferRecord transferRecord = createTransferRecord(uploadTransferObject, "Failed"); dao.addTransferRecord(transferRecord); continue; } } } if (isUploadTimeAvailable) { int timeUntilUploadFinished = getUploadTime(smallWait); //create new webdriverwait based on upload time + some extra time //just in case slow connection WebDriverWait uploadWait = new WebDriverWait(driver, (timeUntilUploadFinished * 60) + (30 * 60)); if (sendingEmail) { isEmailSent = isTransferButtonWithTextAvailable("Send another?", uploadWait); } else if (gettingLink) { isLinkAvailable = isLinkAvailable(uploadWait); } if (!isEmailSent && !isLinkAvailable) { log.error("The upload time is done, but the web element cannot be found"); if (isUploadTimeAvailable(smallWait)) { timeWaited += (timeUntilUploadFinished * 60) + (30 * 60); timeUntilUploadFinished = getUploadTime(smallWait); uploadWait = new WebDriverWait(driver, (timeUntilUploadFinished * 60) + (30 * 60)); //calculate time waited if there's a future failure timeWaited += (timeUntilUploadFinished * 60) + (30 * 60); timeWaited /= 60;//time waited in minutes for failure if (sendingEmail) { isEmailSent = isTransferButtonWithTextAvailable("Send another?", uploadWait); } else if (gettingLink) { isLinkAvailable = isLinkAvailable(uploadWait); } if (!isEmailSent && !isLinkAvailable) { log.error("Couldn't upload this file. Continuing to next file."); TransferRecord transferRecord = createTransferRecord(uploadTransferObject, "Failed"); dao.addTransferRecord(transferRecord); continue; } } else if (sendingEmail && !isTransferButtonWithTextAvailable("Send another?", smallWait)) { log.error("Couldn't upload this file. Continuing to next file."); TransferRecord transferRecord = createTransferRecord(uploadTransferObject, "Failed"); dao.addTransferRecord(transferRecord); continue; } else if (gettingLink && !isLinkAvailable(smallWait)) { log.error("Couldn't upload this file. Continuing to next file."); TransferRecord transferRecord = createTransferRecord(uploadTransferObject, "Failed"); dao.addTransferRecord(transferRecord); continue; } } } WebElement linkElement = null; if (gettingLink) { linkElement = smallWait .until(ExpectedConditions.presenceOfElementLocated(By.className("transfer__textfield"))); downloadLink = linkElement.getAttribute("value"); } if (sendingEmail) { downloadLink = message.getTo().replaceAll(",", " "); } TransferRecord transferRecord = createTransferRecord(uploadTransferObject, downloadLink); dao.addTransferRecord(transferRecord); try { if (gettingLink) { linkElement.click(); clickTransferButtonWithText("Ok"); } else if (isEmailSent) { clickTransferButtonWithText("Send another?"); } clickTransferButtonWithText("Continue"); Thread.sleep(5000); } catch (Exception ex) { log.error("Couldn't click button. Uploading next file.", ex); } } if (loggedIn) { logOut(); try { Thread.sleep(3000); } catch (InterruptedException ex) { log.error(ex); } } clearTableView("upload"); driver.quit(); return null; }
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
private void clickTransferButtonWithText(String text) throws Exception { if (isTransferButtonWithTextAvailable(text, longWait)) { WebElement transferButton = smallWait .until(ExpectedConditions.presenceOfElementLocated(By.className("transfer__button"))); transferButton.click(); } else {// ww w. j a v a 2s.c om throw new Exception("Button with text " + text + " does not exist"); } }
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
private boolean logIn(String emailAddress, String password) { try {// www .jav a 2s .c o m WebElement emailInput = longWait.until(ExpectedConditions.presenceOfElementLocated( By.cssSelector("#signin__form > div > div > form > div:nth-child(1) > input"))); emailInput.sendKeys(emailAddress); WebElement passwordInput = longWait.until(ExpectedConditions.presenceOfElementLocated( By.cssSelector("#signin__form > div > div > form > div:nth-child(2) > input"))); passwordInput.sendKeys(password); WebElement logInButton = longWait.until(ExpectedConditions .presenceOfElementLocated(By.cssSelector("#signin__form > div > div > form > button"))); logInButton.click(); Thread.sleep(5000); return true; } catch (Exception ex) { log.error("Problem", ex); return false; } }
From source file:com.daarons.transfer.UploadTask.java
License:Apache License
private void clickButtonToChooseEmailOrLink() { WebElement emailOrLinkButton = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector( "body > div > div > div.transfer.transfer--half-panel > div > div.transfer__footer > svg"))); emailOrLinkButton.click(); }