Alert window in watin test Javascript

Source: Internet
Author: User
The more I use watin, the more I think it is a good test tool...
However, several examples found on the Internet have problems, and I have not talked about how to test the alert pop-up window. I studied it myself. Finally solved the problem. Make a note in case you forget it.

You must enter a unique email address on the registration page. If an address exists, an alert window is displayed. The test procedure is as follows.
(The unit test tool I used is nunit. Using nunit and watin together has a configuration value problem. Refer to another article.Article)

For simplicity, I put an email input text box on the page.
After you enter the email address, use ajax to verify whether the email address already exists on the server. If yes, the pop-up window prompts that the email exists! Below is the testCode

Public Void Testemail ()
{
Watin. Core. dialoghandlers. alertdialoghandler DH =   New Watin. Core. dialoghandlers. alertdialoghandler ();

IE =   New IE ( " Http: // localhost/reisterandlogin/registeruser. aspx " );

Ie. adddialoghandler (DH ); // Add a control handle


Ie. textfield (find. byname ( " Txtemail " ). Typetext ( " 5a6j@sohu.com " );
Ie. Button (find. byname ( " Btnregister " ). Clicknowait ();


DH. waituntilexists ();
String mess = DH. message;
DH. okbutton. Click (); // Click OK in the window.
Ie. waitforcomplete ();
Ie. removedialoghandler (DH );

Ie. Close ();
Assert. areequal ( " The email address already exists. " , Mess );




}

In particular, there are some tutorials
// DH. waituntilexists (3 );
However, errors always occur. Later, the tutorial on the official website should use DH. waituntilexists (); method.

Now, after running nunit, You can automatically test this code. Convenient and worry-free

 

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.