[Selenium2]+Eclipse+Java環境搭建

來源:互聯網
上載者:User

標籤:java   朋友   開發   項目   selenium2   

一、開發環境:

1、安裝JDK: 
http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html

2、安裝Eclipse 
http://www.eclipse.org/downloads/

3、安裝Selenium:(Java版本) 
http://www.selenium.com/

目前Selenium官網被封殺,有需要的聯絡聯絡我。或者使用代理訪問。

二、建立Java項目與Manve項目

前提條件: 
1、JDK配置成功 
2、Eclipse能正常使用 
3、Selenium(Java版本現在完成)

注意:建立Manve項目需要搭建Manve環境。這裡暫時不說明,有需要的朋友可以聯絡我。QQ:807002272

  1. 新增Java項目[開啟Eclipse—>File—>New—>Other—>Java Project 
    650) this.width=650;" src="http://img.blog.csdn.net/20150706140012616" alt="這裡寫圖片描述" title="" style="border:none;height:auto;" />

    650) this.width=650;" src="http://img.blog.csdn.net/20150706141045600" alt="這裡寫圖片描述" title="" style="border:none;height:auto;" />

    650) this.width=650;" src="http://img.blog.csdn.net/20150706141002318" alt="這裡寫圖片描述" title="" style="border:none;height:auto;" />

  2. 將Selenium配置到項目

    將Selenium解壓後,拷貝到剛剛建立的項目裡面。

    650) this.width=650;" src="http://img.blog.csdn.net/20150706140813738" alt="這裡寫圖片描述" title="" style="border:none;height:auto;" />

    650) this.width=650;" src="http://img.blog.csdn.net/20150706140930025" alt="這裡寫圖片描述" title="" style="border:none;height:auto;" />

  3. 將Jar包檔案配置到Build Path

    650) this.width=650;" src="http://img.blog.csdn.net/20150706141315172" alt="這裡寫圖片描述" title="" style="border:none;height:auto;" />

    650) this.width=650;" src="http://img.blog.csdn.net/20150706141540330" alt="這裡寫圖片描述" title="" style="border:none;height:auto;" />

    selenium-java-2.46.0.jar 
    selenium-java-2.46.0-srcs.jar 
    按照上面圖操作,找到這2個包,進行添加。點擊OK

    650) this.width=650;" src="http://img.blog.csdn.net/20150706141848939" alt="這裡寫圖片描述" title="" style="border:none;height:auto;" />

三、測試環境搭建成功

建立一個Java檔案;輸入以下代碼;使用Java Application運行。

    import org.openqa.selenium.By;    import org.openqa.selenium.WebDriver;    import org.openqa.selenium.WebElement;    import org.openqa.selenium.firefox.*;    public class Snippet {    public static void main(String[] args) {         //如果Firefox瀏覽器沒有預設安裝在C盤,需要制定其路徑        System.setProperty("webdriver.firefox.bin", "D:/Firefox/firefox.exe");         WebDriver driver = new FirefoxDriver();        driver.get("http://wd.txiake.com/");        driver.manage().window().maximize();        WebElement txtbox = driver.findElement(By.name("q"));        txtbox.sendKeys("20150410");        WebElement btn = driver.findElement(By.id("global_search_btns"));        btn.click();        driver.close();    } }


本文出自 “一座舊城,記憶依舊。” 部落格,請務必保留此出處http://diaosi58.blog.51cto.com/2722311/1672000

[Selenium2]+Eclipse+Java環境搭建

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.