個人整理eclipse中匯入selenium
阿新 • • 發佈:2019-01-04
一、安裝好eclipse的前提,環境等都配置好了
二、在專案中右擊Build Path->Configure Build Path
A:在Libraries欄點選Add External JARs
B: selenium-java-2.44.0.zip解壓後的全部和selenium-server-standalone-2.44.0.jar的路徑新增進去
三、測試環境
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class v4_login {
/**
* @param args
*/
public static void main(String[] args) {
//新建一個谷歌驅動瀏覽器例項
WebDriver driver = new ChromeDriver();
//開啟百度首頁
driver.get("http://www.baidu.com");
//根據id獲取輸入框
WebElement textInput = driver.findElement(By.id("kw"));
//在輸入框輸入“Selenium”
textInput.sendKeys("Selenium");
//根據id獲取“百度一下”按鈕
WebElement submit = driver.findElement(By.id("su"));
//點選按鈕
submit.click();
}
}
二、在專案中右擊Build Path->Configure Build Path
A:在Libraries欄點選Add External JARs
B: selenium-java-2.44.0.zip解壓後的全部和selenium-server-standalone-2.44.0.jar的路徑新增進去
三、測試環境
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class v4_login {
/**
* @param args
*/
public static void main(String[] args) {
//新建一個谷歌驅動瀏覽器例項
WebDriver driver = new ChromeDriver();
//開啟百度首頁
driver.get("http://www.baidu.com");
//根據id獲取輸入框
WebElement textInput = driver.findElement(By.id("kw"));
//在輸入框輸入“Selenium”
textInput.sendKeys("Selenium");
//根據id獲取“百度一下”按鈕
WebElement submit = driver.findElement(By.id("su"));
//點選按鈕
submit.click();
}
}