1, the background of a company's website management has a user registration function needs to test, the test is a black box test, please use a table to give the function of the test case (refer to the textbook P107 page). The user registration function is described as follows:
(1) The administrator must first log in, to enter the site management, access to the background management interface can be user registration (assuming that the user registered URL address is http// www.fengt.com/Admin/UserRegister.jsp)
(2) User Registration requirements to enter the user name, password, password confirmation, mailbox, these 4 items can not be empty
(3) The user name requires 6-10 characters, consisting of letters and numbers, and can only begin with a letter. The user name is unique.
(4) password at least 6 digits, including letters, numbers and special symbols (such as:!) + ~ etc)
(5) The mailbox must comply with the mailbox rules
(6) Any requirement above the law should have a corresponding prompt
(7) Registration success must prompt "registration success, please remember password" and jump to the user login page to sign in (assuming the user login page is http://www.fengt.com/Admin/Login.jsp)
Use case ID |
Xxxx-xx-xx |
Use case name |
System Login |
Use case description |
Administrator must first log in, enter the site management, access to the background management interface can be user registration; Registration page information contains the page background display, login user name, password, confirm password, email entry interface, enter data, click Register, if the registration is successful, jump out of the hint " Registration successful, please remember the password "and jump to the user login page |
Use Case Portal |
Open IE, in the Address bar input (http://www.fengt.com/Admin/UserRegister.jsp), into the background management user registration interface, user registration After the successful registration, automatically jump to the background user login interface, to login. |
Test Case ID |
Scene |
Test steps |
Expected results |
Note |
TC1 |
Administrator Login |
Enter login page, enter user name, password to login |
Show Login Success |
|
TC2 |
Access to the Admin interface for user Registration |
Enter the URL address http://www.fengt.com/Admin/UserRegister.jsp Select the user registration module for user registration, |
Successfully entered the registration module |
|
TC3 |
Whether the user name is unique for validation |
Enter a user name that already exists |
Prompt for this user name already exists, please reenter |
|
SCS |
User name Tolerance Verification |
Enter a user name that is not canonical: such as 1,11111111 2, a B 3, 3333aas |
1, prompt input length is not specified range 2, Prompt user name can only be composed of characters, letters and numbers 3. Prompt user name can only start with a letter |
|
TC5 |
Password verification |
Enter the user name for the specification and enter the password that does not conform to the specification:123456 |
Prompted to enter a password that does not conform to the specification, please re-check the input. |
|
TC6 |
Password Confirmation Verification |
Enter a character that is not the same as the password above |
Prompt to reenter the password and the original password does not match, please confirm and re-enter |
|
Scp |
Mailbox Input Validation |
Enter a non-compliant mailbox format:[email protected] |
Prompt to enter the mailbox format is incorrect, please re-enter |
|
TC8 |
Correct input |
Enter the correct user name: Lalala password: zxf520 Confirm password: zxf520 email:[email protected], click Submit |
Prompt input correct, registration successful, and prompt " registration successful, please remember password " |
|
TC9 |
Registration successful |
Page Jump |
Jump into landing page |
|
2, the use of Selenium2 for the Lab05 Project login function to achieve functional automation testing.
Note
L Design test cases should consider the success of the login and unsuccessful two situations;
L LAB05 Project for the experiment 5 to use the project, in everyone's class QQ Group, the database using MySQL, The database file is under the project root directory CreateDataBase.txt
The first step is to add the ID attribute value to the login.jsp landing Page
<%@ page contenttype= "text/html; Charset=utf-8 "%>
User Login </title>
<body>
<form action= "validate.jsp" method= "POST" >
<div align= "center" >
User Login <br><br>
User name: <input type= "text" name= "username" ><br><br>
Dense Code:<input type= "text" name= "password" ><br><br>
<input type= "Submit" value= " login " id= "la" >
</div>
</form>
</body>
2. adding Test Tables and testing cases to Mysql Database
Step Two: Add your own account data to the database
Create Table User
(
ID int auto_increment NOT NULL,
Username varchar (8) NOT NULL,
Password varchar (6) NOT NULL,
Primary KEY (ID)
);
Insert into user values (1, ' Lala ', ' 123456 ');
3. Test Code
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.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
Public class cc {
/**
* @param args
*/
Public Static void Main (string[] args) {
TODO auto-generated Method stub
System. SetProperty ("Webdriver.firefox.bin", "E:\\program Files\\mozilla firefox\\firefox.exe");
Open Firefox Browser
Webdriver Driver = new firefoxdriver ();
Open the page you want to test
Demo.get ("http://localhost:8080/jsp_jdbc/login.jsp");
set the wait time to exceed (in seconds)
Webdriverwait Wait = new webdriverwait (driver, 100);
Locate the User Name entry box and enter the user name automatically
Webelement Txtsearchbox =demo.findelement (by.name ("un")). SendKeys ("CCJ");
Find the Password entry box and enter the password automatically
Webelement Txtsearchbox =demo.findelement (by.name ("PW")). SendKeys ("CCJ");
Locate The login button and click on it
Webelement btn = demo.findelement (By.id ("La")). Click ();
Close Browser
Driver.close ();
}
}
Install seleniumideon Firefoxand record , play back the recording steps, convert the script to Java code
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 BB {
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 = "http://localhost:8080/";
Driver.manage (). Timeouts (). implicitlywait (Timeunit.seconds);
}
@Test
Public void testuntitled () throws Exception {
Driver.get (BaseUrl + "/jsp_jdbc/login.jsp");
Driver.findelement (by.id ("User")). Clear ();
Driver.findelement (by.id ("User")). SendKeys ("Lala");
Driver.findelement (By.id ("pwd")). Clear ();
Driver.findelement (By.id ("pwd")). SendKeys ("123456");
Driver.findelement (By.id ("La")). Click ();
}
@After
Public void TearDown () throws Exception {
Driver.quit ();
String verificationerrorstring = verificationerrors.tostring ();
if (!"". Equals (verificationerrorstring)) {
Fail (verificationerrorstring);
}
}
Private Boolean iselementpresent (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;
}
}
}
Test of software test four black box testing