Selenium简介以及selenium环境搭建
一、Selenium簡介
1.Selenium : 是一款用于Web應(yīng)用程序測試的工具,它支持多平臺、多語言、多瀏覽去實(shí)現(xiàn)自動化測試,支持IE、Chrome、Firefox等瀏覽器
2.架構(gòu):Java+ Eclipse + Selenium + TestNG + ReportNG + Maven+? Jenkins+(Git/SVN)
3.特點(diǎn):
開源、免費(fèi)
多瀏覽器支持:Firefox、Chrome、IE、Opera
多平臺支撐:windows、linux、MAC
對web頁面有良好的支撐
簡單(API簡單)、靈活(用開發(fā)語言驅(qū)動)
支持分布式執(zhí)行測試用例
4.版本:共經(jīng)歷了三個版本selenium 1.0 、selenium2.0、selenium3.0
5.組件:
Selenium IDE :IDE(集成開發(fā)環(huán)境) 支持手工錄制和回放腳本(類似QTP)
Selenium Grid: 支持分布式執(zhí)行測試用例的
Selenium RC:代碼解析器,把java 、python、c#代碼翻譯成瀏覽器能識別的js代碼
WebDriver:是selenium2.0特有的功能,WebDriver通過原生瀏覽器支持或者瀏覽器擴(kuò)展直接控制瀏覽器
二、selenium環(huán)境搭建
1. 安裝JDK1.8即以上版本
2.安裝eclipse? http://www.eclipse.org/downloads/
3.Selenium壓縮包:http://code.google.com/p/selenium/downloads/list (使用FQ軟件才能下載)
注:①如果是Selenium3.0可直接使用Maven拉依賴包,參考Maven使用手冊,pom.xml文檔
? ? ?②手動拉包:先新建一個maven項目,右擊新建的maven項目選擇Build Path,打開以下圖的界面。
?
代碼:
package com.UItest_T56.class1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class baidu1 {
?? public static void main(String[] args) {
?? //啟動 chrome 瀏覽器(獲取Chrome的安裝路徑)
System.setProperty("webdriver.chrome.driver","C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe");
?? //實(shí)例化一個ChromeDriver()? 就是一個網(wǎng)頁
?? WebDriver driver = new ChromeDriver();
?? //打開百度
?? driver.get("https://www.baidu.com");
?? //窗口最大化????
?? driver.manage().window().maximize();
?? //查找要找的元素
?? driver.findElement(By.id("kw")).sendKeys("巫術(shù)");???
?? WebElement btn = driver.findElement(By.id("su"));
?? btn.click();?????????
?? try {
???????? Thread.sleep(3000);//強(qiáng)制睡眠
????? } catch (InterruptedException e) {
????? e.printStackTrace();
????? }
?? driver.close();
?? ?? }
?? }
?
轉(zhuǎn)載于:https://www.cnblogs.com/Joanna-/p/6522533.html
總結(jié)
以上是生活随笔為你收集整理的Selenium简介以及selenium环境搭建的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SetWindowsHookEx
- 下一篇: Tensorflow实现多层感知函数逼近