selenium webdriver学习(一)

package baidu;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

 

public class selenium {

    public static void main (String [] args) throws InterruptedException
    {
         
        String URL="http://www.baidu.com";
        System.setProperty("webdriver.chrome.driver", "E:\\chromedriver.exe"); 
        WebDriver driver = new ChromeDriver();
        driver.get(URL);
 /*
        Navigation navigation = driver.navigate();
         navigation.to(URL);*/
         Thread.sleep(2000);
     //    WebElement keyWord = driver.findElement(By.id("kw1"));
         WebElement keyWord = driver.findElement(By.xpath("//input[@id=‘kw1‘]"));
     
         keyWord.sendKeys("Selenium");
         
          WebElement submit = driver.findElement(By.id("su1"));
          submit.click();
         Thread.sleep(5000);
          System.out.println(driver.getTitle());
         Thread.sleep(5000);
    //     navigation.back();
         
         Thread.sleep(15000);
         System.out.println(driver.getTitle()+"\n"+driver.getCurrentUrl());
         // driver.quit();
       
    }
}

selenium webdriver学习(一),古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。