自动化 sample

package Test;

import java.security.PublicKey;

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

public class Test1 {  

 public static void main(String[] args)

{  

 close();   // TODO Auto-generated method stub   String webBrowserPath ="D:/workspace/Epauto/driver/chromedriver.exe";  

 String webdriverPath="webdriver.chrome.driver";

  String url="http://........";   

  System.setProperty(webdriverPath, webBrowserPath);      WebDriver driver = new ChromeDriver();  

 driver.get("http://.........");   

WebElement edit = driver.findElement(By.name("username"));   edit.sendKeys("tony");   

WebElement edit1 = driver.findElement(By.name("password"));   edit1.sendKeys(".......");  

 WebElement edit2 = driver.findElement(By.name("submit"));   edit2.click();        }      /*private void setElementValue(String elementName,String elementValue)

{     WebElement edit = driver.findElement(By.name(elementName));   edit.sendKeys(elementValue);}*/   

 

 public static void close()

 {   Runtime runtime =Runtime.getRuntime();   

try {    runtime.exec("tskill chrome");    runtime.exec("tskill chromedriver");       }

catch (Exception e) {    // TODO: handle exception   }  } }

posted @ 2015-10-08 15:12  EPTEST  阅读(170)  评论(0编辑  收藏  举报