閩江學院軟體測試實驗四作業

來源:互聯網
上載者:User

標籤:

1、某公司網站的後台管理有一個使用者註冊的功能需要測試,該測試為黑箱測試,請用表格的方式給出該功能的測試案例(參考課本P107頁)。使用者註冊功能描述如下:

(1)       管理員必須先登入,方可進入網站後台管理,進入後台管理介面後可以進行使用者註冊(假設使用者註冊的URL地址為http://www.fengt.com/Admin/UserRegister.jsp)

(2)       使用者註冊要求輸入使用者名稱、密碼、密碼確認、郵箱,這4項內容均不可為空

(3)       使用者名稱要求6-10個字元,由字母和數字構成,且只能以字母開頭。使用者名稱是唯一的。

(4)       密碼至少6位,包含字母、數字和特殊符號(如: !  +  ~ 等)

(5)       郵箱必須符合郵箱規則

(6)       違法以上任何一個要求都應該有相應的提示

(7)       註冊成功需提示“註冊成功,請您記住密碼”,並跳轉到使用者登入頁面進行登入(假設使用者登入頁面為http://www.fengt.com/Admin/Login.jsp)

測試案例ID

情境

測試步驟

測試結果

TC1

管理員登入

開啟登入介面以管理員身份進入

進入後台管理介面

TC2

註冊使用者

在後台管理介面進行使用者註冊,進行使用者名稱,密碼,密碼確認,郵箱等操作

進入使用者註冊頁面

TC3

使用者名稱輸入—空值驗證

未輸入使用者名稱

註冊失敗,提示:使用者名稱不可為空

TC4

使用者名稱輸入—格式驗證

輸入使用者名稱135

註冊失敗,提示:使用者名稱要求6-10個字元,由字母和數字構成,且只能以字母開頭。

TC5

使用者名稱輸入

輸入使用者名稱a13579

註冊成功。

TC6

使用者名稱輸入—驗證使用者名稱重複

輸入使用者名稱a13579

註冊失敗,提示:該使用者已存在。

TC7

密碼輸入—未輸入任何字元

未輸入密碼

輸入失敗,提示:請輸入密碼,密碼不可為空。

TC8

密碼輸入—格式驗證

輸入密碼456

輸入失敗,提示:密碼至少6位,包含字母、數字和特殊符號(如: ! 、.  ~ 等)

TC9

密碼輸入

輸入密碼12345..。

輸入成功。

TC10

郵箱註冊

輸入郵箱[email protected]

輸入成功,提示:註冊成功,請您記住密碼;

TC11

郵箱驗證

輸入錯誤郵箱

提示郵箱輸入錯誤

TC12

註冊成功,跳轉登入頁面

登入介面

使用者登入頁面為http://www.fengt

.com/Admin/Login.jsp

 

 

2、利用Selenium2為Lab05項目中的登入功能實現功能自動化測試。

【注意】

l         設計測試案例時需考慮登入成功和不成功兩種情況;

l         Lab05項目為實驗5用到的項目,在大家的班級QQ群中,資料庫採用MySQL,資料庫檔案在項目根目錄下CreateDataBase.txt

(1)從ECLIPSE開始到瀏覽器

package com.lwk.test;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.WebDriverWait;


public class Test1 {

@Test
public void Test(){

       //如果瀏覽器沒有預設安裝在C盤,需要制定其路徑
       System.setProperty("webdriver.firefox.bin", "E:\\Program Files\\Mozilla           Firefox\\firefox.exe");

//開啟Firefox瀏覽器
WebDriver driver = new FirefoxDriver();
//如果做頁面測試,建議用HttpUnitDriver,這種方式開啟瀏覽器,而是在記憶體中運行,速度比較快
//WebDriver driver = new HtmlUnitDriver();

//開啟要測試的頁面
driver.get("http://www.baidu.com/");
System.out.println("開啟連結——>");

//設定等待超出的時間(100秒)

WebDriverWait wait = new WebDriverWait(driver, 100);

//找到頁面元素,此處是搜尋輸入框
WebElement txtSearchBox = driver.findElement(By.name("wd"));
//設定頁面元素的值,即往輸入框中輸入值
txtSearchBox.sendKeys("selenium2");
//找到搜尋按鈕,並點擊它
WebElement btn = driver.findElement(By.id("su"));
btn.click();

//關閉瀏覽器
//driver.close();
}

}

(2)先錄製,再轉成JAVA代碼

package com.lwk.test;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class Test2 {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();

@Before
public void setUp() throws Exception {
System.setProperty("webdriver.firefox.bin", "E:\\Program Files\\Mozilla Firefox\\firefox.exe");
driver = new FirefoxDriver();
baseUrl = "https://www.baidu.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@Test
public void testUntitled() throws Exception {
driver.get(baseUrl + "/");
driver.findElement(By.id("kw")).click();
driver.findElement(By.id("kw")).click();
driver.findElement(By.id("kw")).click();
driver.findElement(By.id("kw")).clear();
driver.findElement(By.id("kw")).sendKeys("seleniumIDE");
driver.findElement(By.id("su")).click();
driver.findElement(By.id("kw")).click();
}

@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}

private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}

private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}

private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}

 

閩江學院軟體測試實驗四作業

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.