自動化測試selenium+java 環境搭建


1.開發環境:

a:安裝jdk,配置java的環境變量

b:安裝eclipse 工具、火狐瀏覽器(低版本)

2.下載selenium包

selenium-java-2.44.0.jar

selenium-server-standalone-2.45.0.jar

selenium-java-2.44.0-srcs.jar

3.打開eclipse ,將selenium包導入

 

4.再編寫代碼

 

import java.sql.Time;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.server.browserlaunchers.Sleeper;


public class webdriverdemo {

public static void main(String[] args) {

  System.setProperty("webdriver.firefox.bin", "D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
  WebDriver driver = new FirefoxDriver();
  driver.get("https://www.baidu.com");

  WebElement text = driver.findElement(By.name("mobile"));
  text.sendKeys("百度");
  Sleeper.sleepTightInSeconds(1);
  text.submit();
}

}

 編寫完后運行,能運行訪問就ok了

 

 

 

 

 

 

 

 

  覺得不錯的可關注微信公眾號在手機上觀看,讓你用手機邊玩邊看


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM