Package org.openqa.selenium.chrome

Examples of org.openqa.selenium.chrome.ChromeDriver.findElement()


   
    dr.get(filePath);
    Thread.sleep(1000);
   
//    获得其父层级
    List<WebElement> ancestors = dr.findElement(By.className("breadcrumb")).findElements(By.tagName("a"));
    for(WebElement link : ancestors){
      System.out.println(link.getText());
    }
   
//    获取当前层级
View Full Code Here


    }
   
//    获取当前层级
//    由于页面上可能有很多class为active的元素
//    所以使用层级定位最为保险
    WebElement current = dr.findElement(By.className("breadcrumb")).findElement(By.className("active"));
    System.out.println(current.getText());
   
    Thread.sleep(1000);
    System.out.println("browser will be close");
    dr.quit()
View Full Code Here

    System.out.printf("now accesss %s \n", filePath);
   
    dr.get(filePath);
    Thread.sleep(1000);
   
    dr.findElement(By.linkText("Link1")).click();
   
    (new WebDriverWait(dr, 10)).until(new ExpectedCondition<Boolean>(){
      public Boolean apply(WebDriver d){
        return d.findElement(By.id("dropdown1")).isDisplayed();
      }
View Full Code Here

      public Boolean apply(WebDriver d){
        return d.findElement(By.id("dropdown1")).isDisplayed();
      }
    } );
   
    WebElement menu = dr.findElement(By.id("dropdown1")).findElement(By.linkText("Another action"));
    (new Actions(dr)).moveToElement(menu).perform();
   
    Thread.sleep(1000);
    System.out.println("browser will be close");
    dr.quit()
View Full Code Here

    dr.get(filePath);
    Thread.sleep(1000);
   
//    ��λtext��watir-webdriver�������˵�
//    ������ʾ�����˵�
    dr.findElement(By.linkText("Info")).click();
   
    (new WebDriverWait(dr, 10)).until(new ExpectedCondition<Boolean>() {
      public Boolean apply(WebDriver d){
        return d.findElement(By.className("dropdown-menu")).isDisplayed();
      }
View Full Code Here

        return d.findElement(By.className("dropdown-menu")).isDisplayed();
      }
    });
   
//    ͨ��ul�ٲ㼶��λ
    dr.findElement(By.className("dropdown-menu")).findElement(By.linkText("watir-webdriver")).click();
   
    Thread.sleep(1000);
    System.out.println("browser will be close");
    dr.quit()
  }
View Full Code Here

   
    dr.get(filePath);
    Thread.sleep(1000);
   
//    ѡ��checkbox
    dr.findElement(By.cssSelector("input[type=checkbox]")).click();
    Thread.sleep(1000);
   
//    ѡ��radio
    dr.findElement(By.cssSelector("input[type=radio]")).click();
    Thread.sleep(1000);
View Full Code Here

//    ѡ��checkbox
    dr.findElement(By.cssSelector("input[type=checkbox]")).click();
    Thread.sleep(1000);
   
//    ѡ��radio
    dr.findElement(By.cssSelector("input[type=radio]")).click();
    Thread.sleep(1000);
   
//    ѡ�������˵��е����һ��
    List<WebElement> options = dr.findElement(By.tagName("select")).findElements(By.tagName("option"));
    options.get(options.size() - 1).click();
View Full Code Here

//    ѡ��radio
    dr.findElement(By.cssSelector("input[type=radio]")).click();
    Thread.sleep(1000);
   
//    ѡ�������˵��е����һ��
    List<WebElement> options = dr.findElement(By.tagName("select")).findElements(By.tagName("option"));
    options.get(options.size() - 1).click();
    Thread.sleep(1000);
   
//    ����ύ��ť
    dr.findElement(By.cssSelector("input[type=submit]")).click();
View Full Code Here

    List<WebElement> options = dr.findElement(By.tagName("select")).findElements(By.tagName("option"));
    options.get(options.size() - 1).click();
    Thread.sleep(1000);
   
//    ����ύ��ť
    dr.findElement(By.cssSelector("input[type=submit]")).click();
   
    Alert alert = dr.switchTo().alert();
    System.out.println(alert.getText());
    alert.accept();
   
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.