Package org.openqa.selenium

Examples of org.openqa.selenium.WebDriver.findElements()


        try {
            driver.manage();
            driver.navigate();
            driver.switchTo();
            driver.findElement(By.className(""));
            driver.findElements(By.className(""));
            driver.getWindowHandles();

            options.ime();
            options.logs();
            options.timeouts();
View Full Code Here


                break;
              }
          }

          // And now list the suggestions
          List<WebElement> allSuggestions = driver.findElements(By.className("gsq_a"));
         
          for (WebElement suggestion : allSuggestions) {
              System.out.println(suggestion.getText());
          }
       }
View Full Code Here

   
    dr.get(filePath);
    Thread.sleep(1000);
   
//    选择所有的checkbox并全部勾上
    List<WebElement> checkboxes = dr.findElements(By.cssSelector("input[type=checkbox]"));
    for(WebElement checkbox : checkboxes) {
      checkbox.click();
    }
    dr.navigate().refresh();
   
View Full Code Here

   
//    打印当前页面上有多少个checkbox
    System.out.printf("%d\n", checkboxes.size());
   
//    选择页面上所有的input,然后从中过滤出所有的checkbox并勾选之
    List<WebElement> inputs = dr.findElements(By.tagName("input"));
    for(WebElement input : inputs){
      if(input.getAttribute("type").equals("checkbox")){
        input.click();
      }
    }
View Full Code Here

        input.click();
      }
    }
   
//    把页面上最后1个checkbox的勾给去掉
    List<WebElement> allCheckboxes = dr.findElements(By.cssSelector("input[type=checkbox]"));
    allCheckboxes.get(allCheckboxes.size() - 1).click();
   
    Thread.sleep(1000);
    System.out.println("browser will be close");
    dr.quit()
View Full Code Here

        List<WebElement> companyWebElements = new ArrayList<WebElement>(COMPANIES_NUMBER);
        for (int i = 0; i < COMPANIES_NUMBER; i++) {
            companyWebElements.add(mock(WebElement.class));
        }

        when(driver.findElements(By.className(POPULAR_COMPANIES_CLASS_NAME))).thenReturn(companyWebElements);

        return driver;
    }
}
View Full Code Here

        List<WebElement> companyElements = new ArrayList<WebElement>(COMPANIES_NUMBER);
        for (int i = 0; i < COMPANIES_NUMBER; i++) {
            companyElements.add(mock(WebElement.class));
        }

        when(driver.findElements(By.cssSelector(ComplexStructTest.COMPANY_CSS))).thenReturn(companyElements);

        return driver;
    }
}
View Full Code Here

        List<WebElement> radioGroup = Arrays.asList(radioButton, radioButton, radioButton);
        List<WebElement> textInputList = Arrays.asList(textInput, textInput, textInput);
        List<WebElement> htmlElementList = Arrays.asList(htmlElement, htmlElement, htmlElement);
        List<WebElement> webElementList = Arrays.asList(element, element, element);

        when(driver.findElements(new ByAll(By.id(ELEMENT_ID)))).thenReturn(webElementList);
        when(driver.findElements(new ByAll(By.id(ELEMENT_ID), By.id(HTML_ELEMENT_ID))))
                .thenReturn(Arrays.asList(element, element, element, htmlElement, htmlElement, htmlElement));
        when(driver.findElement(new ByAll(By.id(ELEMENT_ID)))).thenReturn(element);
        when(driver.findElement(new ByAll(By.id(HTML_ELEMENT_ID)))).thenReturn(htmlElement);
        when(driver.findElement(new ByAll(By.id(ELEMENT_ID), By.id(HTML_ELEMENT_ID), By.id(BUTTON_ID))))
View Full Code Here

        List<WebElement> textInputList = Arrays.asList(textInput, textInput, textInput);
        List<WebElement> htmlElementList = Arrays.asList(htmlElement, htmlElement, htmlElement);
        List<WebElement> webElementList = Arrays.asList(element, element, element);

        when(driver.findElements(new ByAll(By.id(ELEMENT_ID)))).thenReturn(webElementList);
        when(driver.findElements(new ByAll(By.id(ELEMENT_ID), By.id(HTML_ELEMENT_ID))))
                .thenReturn(Arrays.asList(element, element, element, htmlElement, htmlElement, htmlElement));
        when(driver.findElement(new ByAll(By.id(ELEMENT_ID)))).thenReturn(element);
        when(driver.findElement(new ByAll(By.id(HTML_ELEMENT_ID)))).thenReturn(htmlElement);
        when(driver.findElement(new ByAll(By.id(ELEMENT_ID), By.id(HTML_ELEMENT_ID), By.id(BUTTON_ID))))
                .thenReturn(htmlElement);
View Full Code Here

        when(driver.findElement(By.id(TEXT_INPUT_ID))).thenReturn(textInput);
        when(driver.findElement(By.id(BUTTON_ID))).thenReturn(button);
        when(driver.findElement(By.name(RADIO_NAME))).thenReturn(radioButton);
        when(driver.findElement(By.name(IMAGE_NAME))).thenReturn(image);

        when(driver.findElements(By.name(RADIO_NAME))).thenReturn(radioGroup);
        when(driver.findElements(By.id(TEXT_INPUT_ID))).thenReturn(textInputList);
        when(driver.findElements(By.id(HTML_ELEMENT_ID))).thenReturn(htmlElementList);
        when(driver.findElements(By.id(ELEMENT_ID))).thenReturn(webElementList);

        when(radioButton.getAttribute("name")).thenReturn(RADIO_NAME);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.