Package org.openqa.selenium

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


    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

    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();
    Thread.sleep(1000);
   
    System.out.println("browser will be close");
    dr.quit()
  }
View Full Code Here

   
    dr.get(filePath);
    Thread.sleep(1000);
   
//    copy content of A
    dr.findElement(By.id("A")).sendKeys(Keys.chord(Keys.CONTROL + "a"));
    Thread.sleep(1000);
    dr.findElement(By.id("A")).sendKeys(Keys.chord(Keys.CONTROL + "x"));
   
//    paste to B
    dr.findElement(By.id("B")).sendKeys(Keys.chord(Keys.CONTROL + "v"));
View Full Code Here

    System.out.printf("now accesss %s \n", filePath);
   
    dr.get(filePath);
    Thread.sleep(1000)
   
    WebElement textField = dr.findElement(By.name("user"));
    System.out.println(textField.isEnabled());
   
//    直接用isEnabled方法去判断该button的话返回的会是true
//    这是因为button是使用css方法去disabled的,并不是真正的disable
//    这时候需要判断其class里是否有disabled这值来判断其是否处于disable状态
View Full Code Here

    System.out.println(textField.isEnabled());
   
//    直接用isEnabled方法去判断该button的话返回的会是true
//    这是因为button是使用css方法去disabled的,并不是真正的disable
//    这时候需要判断其class里是否有disabled这值来判断其是否处于disable状态
    System.out.println(dr.findElement(By.className("btn")).isEnabled());
   
//    隐藏掉textField
//    判断其是否显示
    ((JavascriptExecutor)dr).executeScript("$(arguments[0]).hide()", textField);
    System.out.println(textField.isDisplayed());
View Full Code Here

    Thread.sleep(1000);
   
//    copy content of A
    dr.findElement(By.id("A")).sendKeys(Keys.chord(Keys.CONTROL + "a"));
    Thread.sleep(1000);
    dr.findElement(By.id("A")).sendKeys(Keys.chord(Keys.CONTROL + "x"));
   
//    paste to B
    dr.findElement(By.id("B")).sendKeys(Keys.chord(Keys.CONTROL + "v"));
   
//    SendKeys to A
View Full Code Here

//    判断其是否显示
    ((JavascriptExecutor)dr).executeScript("$(arguments[0]).hide()", textField);
    System.out.println(textField.isDisplayed());
   
//    使用click方法选择raido
    WebElement radio = dr.findElement(By.name("radio"));
    radio.click();
    System.out.println(radio.isSelected());
   
    try{
      dr.findElement(By.id("none"));
View Full Code Here

    dr.findElement(By.id("A")).sendKeys(Keys.chord(Keys.CONTROL + "a"));
    Thread.sleep(1000);
    dr.findElement(By.id("A")).sendKeys(Keys.chord(Keys.CONTROL + "x"));
   
//    paste to B
    dr.findElement(By.id("B")).sendKeys(Keys.chord(Keys.CONTROL + "v"));
   
//    SendKeys to A
    dr.findElement(By.id("A")).sendKeys(Keys.chord("watir webdriver is better than selenium webdriver"));
   
    Thread.sleep(1000);
View Full Code Here

   
//    paste to B
    dr.findElement(By.id("B")).sendKeys(Keys.chord(Keys.CONTROL + "v"));
   
//    SendKeys to A
    dr.findElement(By.id("A")).sendKeys(Keys.chord("watir webdriver is better than selenium webdriver"));
   
    Thread.sleep(1000);
    System.out.println("browser will be close");
    dr.quit()
  }
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.