Package org.openqa.selenium.chrome

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


    dr.get(filePath);
    Thread.sleep(1000);
   
//    获得所有分页的数量
//    -2是因为要去掉上一个和下一个
    int total_pages = dr.findElement(By.className("pagination")).findElements(By.tagName("li")).size() - 2;
    System.out.printf("Total page is %d\n", total_pages);
   
//    取当前页面的url以及当前页面是第几页
    WebElement current_page = dr.findElement(By.className("pagination")).findElement(By.className("active"));
    System.out.printf("Current page is %s\n", current_page.getText());
View Full Code Here


//    -2是因为要去掉上一个和下一个
    int total_pages = dr.findElement(By.className("pagination")).findElements(By.tagName("li")).size() - 2;
    System.out.printf("Total page is %d\n", total_pages);
   
//    取当前页面的url以及当前页面是第几页
    WebElement current_page = dr.findElement(By.className("pagination")).findElement(By.className("active"));
    System.out.printf("Current page is %s\n", current_page.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);
   
    WebElement link = dr.findElement(By.id("tooltip"));
   
//    获得tooltip的内容
    System.out.println(link.getAttribute("data-original-title"));
   
//    获取该链接的text
View Full Code Here

   
    dr.get(filePath);
    Thread.sleep(1000);
   
//    ������ӵ���alert
    dr.findElement(By.id("tooltip")).click();
   
    Alert alert = dr.switchTo().alert();
    alert.accept();
           
    Thread.sleep(1000);
View Full Code Here

   
    dr.get(filePath);
    Thread.sleep(2000);
   
//    by id
    dr.findElement(By.id("inputEmail")).click();
    Thread.sleep(1000);
   
//    by name
    dr.findElement(By.name("password"));
    Thread.sleep(1000);
View Full Code Here

//    by id
    dr.findElement(By.id("inputEmail")).click();
    Thread.sleep(1000);
   
//    by name
    dr.findElement(By.name("password"));
    Thread.sleep(1000);
   
//    by tagname
    String classOfForm = dr.findElement(By.tagName("form")).getAttribute("class");
    System.out.printf("%s\n", classOfForm);
View Full Code Here

//    by name
    dr.findElement(By.name("password"));
    Thread.sleep(1000);
   
//    by tagname
    String classOfForm = dr.findElement(By.tagName("form")).getAttribute("class");
    System.out.printf("%s\n", classOfForm);
    Thread.sleep(1000);
   
//    by link text
    WebElement link = dr.findElement(By.linkText("register"));
View Full Code Here

    String classOfForm = dr.findElement(By.tagName("form")).getAttribute("class");
    System.out.printf("%s\n", classOfForm);
    Thread.sleep(1000);
   
//    by link text
    WebElement link = dr.findElement(By.linkText("register"));
    ((JavascriptExecutor)dr).executeScript("$(arguments[0]).fadeOut().fadeIn()", link);
    Thread.sleep(1000);

//    by partial link test
    WebElement sameLink = dr.findElement(By.partialLinkText("reg"));
View Full Code Here

    WebElement link = dr.findElement(By.linkText("register"));
    ((JavascriptExecutor)dr).executeScript("$(arguments[0]).fadeOut().fadeIn()", link);
    Thread.sleep(1000);

//    by partial link test
    WebElement sameLink = dr.findElement(By.partialLinkText("reg"));
    ((JavascriptExecutor)dr).executeScript("$(arguments[0]).fadeOut().fadeIn()", sameLink);
    Thread.sleep(1000);
   
//    by css selector
    WebElement div = dr.findElement(By.cssSelector(".controls"));
View Full Code Here

    WebElement sameLink = dr.findElement(By.partialLinkText("reg"));
    ((JavascriptExecutor)dr).executeScript("$(arguments[0]).fadeOut().fadeIn()", sameLink);
    Thread.sleep(1000);
   
//    by css selector
    WebElement div = dr.findElement(By.cssSelector(".controls"));
    ((JavascriptExecutor)dr).executeScript("$(arguments[0]).fadeOut().fadeIn()", div);
    Thread.sleep(1000);
   
//    by xpath
    dr.findElement(By.xpath("/html/body/form/div[3]/div/label/input")).click();
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.