Minjiang College Software test lab four jobs

Source: Internet
Author: User

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)

Test case ID

Scene

Test steps

Test results

TC1

Administrator Login

Open the Login interface to enter as an administrator

Access to the Admin interface

TC2

Registered users

In the background management interface for user registration, user name, password, password confirmation, mailbox and other operations

Go to User registration page

TC3

User name Input-null value verification

User name not entered

Registration failed, prompt: User name cannot be empty

TC4

User name Input-format verification

Enter User name 135

Registration failed, hint: The user name requires 6-10 characters, consisting of letters and numbers, and can only start with a letter.

Scr

User name Input

Enter user name a13579

Registration is successful.

TC6

User name Input-Verify duplicate user name

Enter user name a13579

Registration failed with prompt: The user already exists.

TC7

Password input-no characters entered

Password not entered

Input failed, prompt: Please enter password, password cannot be empty.

TC8

Password Input-format verification

Enter your password 456

Input failed, hint: password at least 6 bits, including letters, numbers and special symbols such as:!  、. ~ etc)

TC9

Password input

Enter Password 12345 ...

The input was successful.

TC10

Email registration

Enter email [email protected]

Input success, prompt: Registration success, please remember the password;

TC11

Mailbox Verification

Enter the wrong mailbox

Prompt for mailbox input errors

TC12

Registration successful, jump login page

Login interface

User Login page is http://www.fengt

. com/admin/login.jsp

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, database files in the project root directory CreateDataBase.txt

(1) Start from Eclipse to browser

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 () {

If the browser is not installed by default on the C drive, you need to develop its path
System.setproperty ("Webdriver.firefox.bin", "E:\\program Files\\mozilla firefox\\firefox.exe");

Open Firefox browser
Webdriver Driver = new Firefoxdriver ();
If you do a page test, it is recommended to use Httpunitdriver, this way to open the browser, but in memory run, faster
Webdriver Driver = new Htmlunitdriver ();

Open the page you want to test
Driver.get ("http://www.baidu.com/");
SYSTEM.OUT.PRINTLN ("Open link-up");

Set the wait time to exceed (100 seconds)

webdriverwait wait = new webdriverwait (driver, 100);

Find the page element, here is the search input box
Webelement Txtsearchbox = driver.findelement (By.name ("WD"));
Set the value of the page element, i.e. enter a value into the input box
Txtsearchbox.sendkeys ("selenium2");
Find the Search button and click on it
Webelement btn = driver.findelement (by.id ("su"));
Btn.click ();

Close browser
Driver.close ();
}

}

(2) record first, then turn into Java code

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 (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) {
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;
}
}
}

Minjiang College Software test lab four jobs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.