Click here to Skip to main content
15,896,606 members
Articles / Programming Languages / Visual Basic

WatiN Test Recorder

Rate me:
Please Sign up or sign in to vote.
5.00/5 (12 votes)
14 Jun 2007GPL34 min read 148.4K   5.2K   43  
Automate web test recording into C#, VB.NET and PHP
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DemoApp
{
    public partial class frmAuthenticate : Form
    {
        private bool m_AuthSuccess = false;
        public string m_Username = string.Empty;
        public string m_Password = string.Empty;

        private void ResetAllFields()
        {
            m_AuthSuccess = false;
            m_Username = string.Empty;
            m_Password = string.Empty;
            txtUserName.Text = string.Empty;
            txtPassword.Text = string.Empty;
            chkViewPassword.Text = "Show Password";
            txtPassword.PasswordChar = '*';
        }

        public frmAuthenticate()
        {
            InitializeComponent();
        }

        public DialogResult ShowDialogInternal(IWin32Window owner)
        {
            ResetAllFields();
            this.ShowDialog(owner);
            return (m_AuthSuccess) ? DialogResult.OK : DialogResult.Cancel;
        }

        private void chkViewPassword_Click(object sender, EventArgs e)
        {
            if (chkViewPassword.Checked)
            {
                chkViewPassword.Text = "Hide Password";
                txtPassword.PasswordChar = new char();
            }
            else
            {
                chkViewPassword.Text = "Show Password";
                txtPassword.PasswordChar = '*';
            }
        }

        private void frmAuthenticate_Load(object sender, EventArgs e)
        {
            this.Icon = AllForms.BitmapToIcon(14);
        }

        private void frmAuthenticate_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                e.Cancel = true;
                this.Hide();
            }
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            m_AuthSuccess = true;
            m_Username = txtUserName.Text;
            m_Password = txtPassword.Text;
            this.Hide();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            //Just hide
            this.Hide();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Web Developer
United States United States
Raised by wolves in the mean streets of Macintosh C/C++ for IBM and Motorola, moved on to Delphi and now C#. Ah, the mother's milk of Microsoft...

Comments and Discussions