List of usage examples for org.openqa.selenium WebElement getText
String getText();
From source file:akori.FeaturesSelenide.java
public static void main(String[] args) throws Exception { System.out.println("esto es FeaturesSelenide"); PrintWriter writer = new PrintWriter("features.txt", "UTF-8"); try {// w ww . j a v a 2 s . c om String URL = "http://www.mbauchile.cl"; open(URL); SelenideElement s = $(By.tagName("body")); Document doc = Jsoup.connect(URL).timeout(0).get(); Elements e1 = doc.body().getAllElements(); ArrayList<String> tags = new ArrayList<String>(); int i = 1; for (Element temp : e1) { if (tags.indexOf(temp.tagName()) == -1) { tags.add(temp.tagName()); ElementsCollection query = $$(By.tagName(temp.tagName())); for (SelenideElement temp2 : query) { WebElement temp1 = temp2.toWebElement(); Point po = temp1.getLocation(); Dimension d = temp1.getSize(); if (d.width <= 0 || d.height <= 0 || po.x < 0 || po.y < 0) { continue; } if (temp1.getTagName().equals("img")) { writer.print(i + "," + temp1.getTagName() + "," + po.x + "," + po.y + "," + d.width + "," + d.height + "," + temp1.getAttribute("class") + "," + temp1.getAttribute("src")); int j = 1; for (j = 1; !temp2.equals(s); ++j) { temp2 = temp2.parent(); if (j > 100) break; } writer.println("," + j); } else if (temp1.getTagName().equals("a")) { writer.println(i + "," + temp1.getTagName() + "," + po.x + "," + po.y + "," + d.width + "," + d.height + "," + temp1.getAttribute("class") + "," + temp1.getAttribute("href")); int j = 1; for (j = 1; !temp2.equals(s); ++j) { temp2 = temp2.parent(); if (j > 100) break; } writer.println("," + j); } else { writer.println(i + "," + temp1.getTagName() + "," + po.x + "," + po.y + "," + d.width + "," + d.height + "," + temp1.getAttribute("class") + "," + temp1.getText()); int j = 1; for (j = 1; !temp2.equals(s); ++j) { temp2 = temp2.parent(); if (j > 100) break; } writer.println("," + j); } ++i; } } } } catch (Exception e) { e.printStackTrace(); } writer.close(); }
From source file:android.pages.DirectoriesPageAndroid.java
private void findElementByTextOnListAndClick(String text) { try {/*from w w w .ja v a2s. c om*/ Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } List<WebElement> elements = findListOfElementsById(listOfElements); m: for (WebElement element : elements) { if (element.getText().equals(text)) { element.click(); System.out.println("Clicked on: " + text); break m; } } }
From source file:app.fynd.Pages.MajorFlowSanityPage.java
License:Open Source License
/** * Follow the Brand//from ww w. j a va 2s .c o m * @throws InterruptedException */ public void followBrand() throws InterruptedException { brandTopMenuList.click(); scroll(1); for (WebElement webElement : brandListFollowButton) { System.out.println(webElement.getText()); } brandListFollowButton.get(0).getText(); brandListFollowButton.get(0).click(); }
From source file:app.fynd.Pages.MajorFlowSanityPage.java
License:Open Source License
/** * clicks on top sub menu//w ww . ja v a2s .c o m * @throws InterruptedException */ public void selectTopMenu(String Text) throws InterruptedException { for (WebElement webElement : subMenuList) { System.out.println(webElement.getText()); } switch (Text) { case "For You": subMenuList.get(1).click(); break; case "Brands": subMenuList.get(7).click(); System.out.println(subMenuList.get(2).getText()); break; case "collections": subMenuList.get(8).click(); break; case "My Fynds": subMenuList.get(9).click(); break; default: subMenuList.get(10).click(); break; } }
From source file:app.fynd.Pages.MajorFlowSanityPage.java
License:Open Source License
public void selectPaymentMethod(String paymentType) throws InterruptedException, MalformedURLException { //waitgetForPageLoadAndroid(60).until(ExpectedConditions.presenceOfElementLocated(MobileBy.AndroidUIAutomator("new UiSelector().resourceId(\"co.go.fynd:id/menu_icon\")"))).isDisplayed(); //List<WebElement> paymentcontainers=getAndroidDriver().findElements(MobileBy.AndroidUIAutomator("new UiSelector().resourceId(\"co.go.fynd:id/menu_icon\")")); List<WebElement> paymentcontainers = paymentSelector; // int size =paymentcontainers.size(); // paymentcontainers.get(size).s ScrolltoElementWithText(paymentType); for (WebElement webElement : paymentcontainers) { System.out.println(webElement.getText()); if (webElement.getText().equals(paymentType)) { webElement.click();/*from w w w .j av a 2 s .c o m*/ System.out.println("Selected the Bank"); break; } } // switch (paymentType) { // case "Add new cards":{ // //TODO // paymentcontainers.get(3).click(); // } // // break; // case "ICICI":{ // paymentcontainers.get(4).click(); // } // break; // case "HDFC":{ // paymentcontainers.get(5).click(); // } // break; // // case "AXIS":{ // paymentcontainers.get(6).click(); // } // break; // // case "SBI":{ // paymentcontainers.get(7).click(); // } // break; // case "KOTAK":{ // paymentcontainers.get(8).click(); // } // break; // case "PAYTM":{ // paymentcontainers.get(9).click(); // } // break; // case "MOBIKWIK":{ // paymentcontainers.get(10).click(); // } // break; // case "PAYUMONEY":{ // paymentcontainers.get(11).click(); // } // break; // case "OLAMONEY":{ // paymentcontainers.get(12).click(); // } // case "FREECHARGE":{ // paymentcontainers.get(13).click(); // } // break; // default:{ // paymentcontainers.get(4).click(); // } // break; // } // }
From source file:app.Stepdefs.java
@Given("^Edit is pressed for key \"([^\"]*)\"$") public void edit_is_pressed_for_key(String key) throws Throwable { // let's get all the <td> -elements from HTML List<WebElement> lista = driver.findElements(By.tagName("td")); int indeksi = 0; for (int i = 0; i < lista.size(); i++) { WebElement element = lista.get(i); // there are four columns: checkbox, reference, tags, edit if (element.getText().contains(key)) { indeksi = i + 2; // element + 2 -> get the edit -element break; }//from ww w .ja v a 2s . c o m } if (indeksi > 0) { // let's press the founded EDIT button (submit doesn't work) lista.get(indeksi).click(); } Thread.sleep(2000); }
From source file:app.Stepdefs.java
@When("^link tag by name \"([^\"]*)\" is pressed$") public void link_tag_by_name_is_pressed(String tag) throws Throwable { List<WebElement> lista = driver.findElements(By.tagName("span")); for (WebElement element : lista) { if (element.getText().contains(tag)) { element.click();//from w w w . j a v a 2 s . c o m } } Thread.sleep(2000); }
From source file:applicationdriverlayer.pageobjects.squash.booking.CourtAndTimeSlotChooserPage.java
License:Apache License
public List<java.time.LocalTime> getAllPossibleBookingStartTimes() { // Use HashSet to avoid duplicate entries from right and left of screen HashSet<java.time.LocalTime> startTimes = new HashSet<>(); for (WebElement element : timeSlotLabels) { startTimes.add(java.time.LocalTime.parse(element.getText(), DateTimeFormatter.ofPattern("h:mm a"))); }//from w w w . ja v a2 s .com // Ensure we return the times in earlier-to-later order List<java.time.LocalTime> startTimesList = new ArrayList<>(); startTimesList.addAll(startTimes); Collections.sort(startTimesList, (java.time.LocalTime t1, java.time.LocalTime t2) -> t1.compareTo(t2)); return startTimesList; }
From source file:at.ac.tuwien.big.testsuite.impl.selenium.LoginTest.java
License:Apache License
private void checkMessages(String message, Matcher<String> matcher) { WebElement loginMessagesElement = null; if (exists(By.id("login_messages"))) { loginMessagesElement = driver.findElement(By.id("login_messages")); } else if (exists(By.id("form:login_messages"))) { loginMessagesElement = driver.findElement(By.id("form:login_messages")); } else if (exists(By.id("login:form:login_messages"))) { loginMessagesElement = driver.findElement(By.id("login:form:login_messages")); }/*from ww w . j a v a2s. c om*/ String text = loginMessagesElement == null ? null : loginMessagesElement.getText(); checkThat(message, text, matcher); }
From source file:at.ac.tuwien.big.testsuite.impl.selenium.RegisterTest.java
License:Apache License
/** * Performs the given matcher check with the text of the WebElement with the * given id and stores the result in the error collector. If no element is * found with the given Id, the check is performed against null. * * @param message the message to be used if the check fails * @param elementIds the possible ids of the WebElement to check * @param matcher the matcher to be used in the check *//*from w w w . jav a2 s . c o m*/ private void checkMessages(String message, String[] elementIds, Matcher<String> matcher) { String elementId = elementIds[0]; for (String tmp : elementIds) { for (String tmpPrefix : ID_PREFIXES) { if (exists(By.id(tmpPrefix + tmp + "_messages"))) { elementId = tmpPrefix + tmp; break; } } } WebElement messagesElement = null; List<WebElement> elements = driver.findElements(By.id(elementId + "_messages")); if (!elements.isEmpty()) { messagesElement = elements.get(0); } String text = messagesElement == null ? null : messagesElement.getText(); checkThat(message, text, matcher); }