List of usage examples for org.openqa.selenium WebElement getAttribute
String getAttribute(String name);
From source file:com.continuuity.test.pagetest.IndexTest.java
License:Apache License
@Test public void test_08_catalogPanel() throws Exception { // Verify panel title WebElement servicesPanel = TEST_UTIL.getPanelHead(CLUSTERTEMPLATE); assertEquals("Catalog", servicesPanel.getText()); assertEquals(Constants.INDEX_URL + Constants.CLUSTERTEMPLATE_HREF, servicesPanel.getAttribute(HREF)); Map<String, ClusterTemplate> nameServices = EXAMPLE_READER .getClusterTemplate(Constants.CLUSTERTEMPLATE_PATH); // Verify the table in the panel WebElement table = TEST_UTIL.getTable(Constants.CLUSTERTEMPLATE_TABLE); assertEquals("The number of rows is not equal to the number of providers in the examples.", nameServices.size(), TEST_UTIL.getRowCount(table)); for (int row = 0; row < TEST_UTIL.getRowCount(table); row++) { String name = TEST_UTIL.getTd(table, row, 0); assertTrue("Name is not in the examples.", nameServices.containsKey(name)); assertEquals("Description is not equal.", nameServices.get(name).getDescription(), TEST_UTIL.getTd(table, row, 1)); }//from ww w. j av a 2s . c om }
From source file:com.continuuity.test.TestUtil.java
License:Apache License
public Set<String> getTopList(WebDriver driver) { Set<String> topList = Sets.newHashSet(); for (WebElement element : driver.findElements(TYPES)) { topList.add(element.getAttribute(Constants.TEXT)); }//from w w w. j a v a 2s . c o m return topList; }
From source file:com.continuuity.test.TestUtil.java
License:Apache License
public Set<String> getTopListUri(WebDriver driver) { Set<String> topListUri = Sets.newHashSet(); for (WebElement element : driver.findElements(TYPES)) { topListUri.add(element.getAttribute(Constants.HREF)); }/* w w w . j a v a 2 s . c o m*/ return topListUri; }
From source file:com.conwet.silbops.EndToEndHTMLIT.java
License:Open Source License
@Test public void shouldCloseConnection() { System.out.println("start close connection test..."); shouldOpenConnection();//from w ww . j a v a2s . c om 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.UploadTask.java
License:Apache License
@Override protected Object call() throws Exception { initUploadTask();/*from ww w.j av a 2 s. c om*/ 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 String getTransformAttribute(WebElement button) { String transform = button.getAttribute("transform"); return transform; }
From source file:com.denimgroup.threadfix.selenium.pages.BasePage.java
License:Mozilla Public License
public void waitForInvisibleElement(WebElement e) { WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id(e.getAttribute("id")))); }
From source file:com.dhenton9000.filedownloader.FileDownloader.java
License:Apache License
/** * Perform an HTTP Status Check upon/Download the file specified in the href attribute of a WebElement * * @param anchorElement Selenium WebElement * @throws Exception/*from ww w . j ava 2s . c o m*/ */ public void setURISpecifiedInAnchorElement(WebElement anchorElement) throws Exception { if (anchorElement.getTagName().equals("a")) { fileURI = new URI(anchorElement.getAttribute("href")); } else { throw new Exception("You have not specified an <a> element!"); } }
From source file:com.dhenton9000.filedownloader.FileDownloader.java
License:Apache License
/** * Perform an HTTP Status Check upon/Download the image specified in the src attribute of a WebElement * * @param imageElement Selenium WebElement * @throws Exception/*from w w w . ja v a 2 s .c o m*/ */ public void setURISpecifiedInImageElement(WebElement imageElement) throws Exception { if (imageElement.getTagName().equals("img")) { fileURI = new URI(imageElement.getAttribute("src")); } else { throw new Exception("You have not specified an <img> element!"); } }
From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Broadband_Util.java
/** * Read the 90Days Graph data//from w ww . j a va2 s . c om */ protected void targetGraphData_90Days() { Wait<WebDriver> wait = new WebDriverWait(getDriver(), 30); JavascriptExecutor jse = (JavascriptExecutor) getDriver(); Map<String, String> mapbill = new HashMap<String, String>(); jse.executeScript("window.scrollBy(0,-500)", ""); jse.executeScript("window.scrollBy(0,225)", ""); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//*[name()='svg']/*[name()='g'][13]/*[name()='g'][1]"))); handleLink_ByText(AppConstants.DAYS_90); //Working :get the stroke attribute to get the color value of graph getDriver().manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); boolean breakIt = true; //Get the BillCycle Elements String billcyclerootNodeXpath = "//*[name()='svg']/*[name()='g'][13]/*[name()='g'][1]"; WebElement billcyclerootElement = getDriver().findElement(By.xpath(billcyclerootNodeXpath)); String billcyclechildXpath = "./*[name()='text']"; List<WebElement> listbillcyclechild = billcyclerootElement.findElements(By.xpath(billcyclechildXpath)); int eleListSize = listbillcyclechild.size(); // System.out.println("listChildElements.size() : " + listbillcyclechild.size()); //Get the BillCycle Graph , tooltip Elements String bcGraphRootNodeXpath = "//*[name()='svg']/*[name()='g'][6]/*[name()='g']"; WebElement bcGraphRootElement = getDriver().findElement(By.xpath(bcGraphRootNodeXpath)); String bcGraphChildXpath = "./*[name()='g']"; List<WebElement> listbcGraphChild = bcGraphRootElement.findElements(By.xpath(bcGraphChildXpath)); int bcGraphListSize = listbcGraphChild.size(); if (bcGraphListSize > 0) { targetBCGraphData_90Days = new HashMap(); } // System.out.println("bcGraphListSize.size() : " + listbcGraphChild.size()); for (int j = 0; j < eleListSize; j++) { int n = j + 1; Map<String, String> tempBCGData = new HashMap(); String billCycleDate = null; String bcAtrribute_color = null; while (true) { breakIt = true; try { //read the billcycle data from nodes String billchildNodePath_startDate = billcyclerootNodeXpath.concat("/*[name()='text']") .concat("[").concat(String.valueOf(n).concat("]").concat("/*[name()='tspan'][1]")); WebElement billelement_startDate = getDriver() .findElement(By.xpath(billchildNodePath_startDate)); //Thread.sleep(2000); String billAtrribute_startDate = billelement_startDate.getText(); String billchildNodePath_endDate = billcyclerootNodeXpath.concat("/*[name()='text']") .concat("[").concat(String.valueOf(n).concat("]").concat("/*[name()='tspan'][2]")); WebElement billelement_endDate = getDriver().findElement(By.xpath(billchildNodePath_endDate)); String billAtrribute_endDate = billelement_endDate.getText(); billCycleDate = billAtrribute_startDate.concat("_").concat(billAtrribute_endDate); //System.out.println("Bill Cycle : '" + n+"' -->"+ billCycleDate); //read the billcycle graph data - color, tooltip from nodes String billchildNodePath_color = bcGraphRootNodeXpath.concat("/*[name()='g']").concat("[") .concat(String.valueOf(n).concat("]").concat("/*[name()='path']")); //System.out.println("Node billchildNodePath_color : " + billchildNodePath_color); WebElement billelement_color = getDriver().findElement(By.xpath(billchildNodePath_color)); bcAtrribute_color = billelement_color.getAttribute("stroke"); String colorMap = AppConstants.COLOR.concat(AppConstants.BEGIN_BRACKET).concat(billCycleDate) .concat(AppConstants.CLOSE_BRACKET); tempBCGData.put(colorMap, bcAtrribute_color); Actions builder = new Actions(getDriver()); String childMouseHouverNode = bcGraphRootNodeXpath.concat("/*[name()='g']").concat("[") .concat(String.valueOf(n).concat("]")); builder.moveToElement(getDriver().findElement(By.xpath(childMouseHouverNode))).perform(); WebElement mouseHoverNodeElement = getDriver() .findElement(By.xpath("//div[9]/div[1]/div[1]/div[2]/div/div/div")); if (mouseHoverNodeElement != null) { String toolTipText = mouseHoverNodeElement.getText(); //System.out.println("toolTipText : '" + n+"' "+toolTipText ); String toolTipTextMap = AppConstants.TOOL_TIP_TEXT.concat(AppConstants.BEGIN_BRACKET) .concat(billCycleDate).concat(AppConstants.CLOSE_BRACKET); //tempBCGData.put(toolTipTextMap, toolTipText.replaceAll("\n", "")); tempBCGData.put(toolTipTextMap, toolTipText); builder.moveToElement(getDriver().findElement(By.xpath(billchildNodePath_startDate))) .click().perform(); } } catch (Exception e) { if (e.getMessage().contains("element is not attached")) { //System.out.println("Error: Element 4 "); breakIt = false; } } if (breakIt) { break; } } //while loop ends targetBCGraphData_90Days.put(billCycleDate, tempBCGData); } //for loop ends }