Fourth time assignment

Source: Internet
Author: User

Test case ID

Scene

Test steps

Test results

Text1

Administrator Login

Open the Login interface to enter as an administrator

Access to the Admin interface

Text2

Registered users

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

Go to User registration page

Text3

User name Input-null value verification

User name not entered

Registration failed, prompt: User name cannot be empty

Text4

User name Input-format verification

Enter user name 2468

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

Text5

User name Input

Enter user name a2468

Registration is successful.

Text6

User name Input-Verify duplicate user name

Enter user name a2468

Registration failed with prompt: The user already exists.

Text7

Password input-no characters entered

Password not entered

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

Text8

Password Input-format verification

Enter your password 123

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

Text9

Password input

Enter Password a12345

The input was successful.

Text10

Email registration

Enter email [email protected]

Enter success, prompt: Registration is successful, please remember the password.

Text11

Mailbox Verification

Enter the wrong mailbox

Prompt for mailbox input error.

Text12

Registration successful, jump login page

Login interface

User Login page is http://www.fengt

. com/admin/login.jsp

(1) Start from Eclipse to browser

Package com.zengqiang.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. zengqiang.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;
}
}
}

Fourth time assignment

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.