watin-html element and element attribute recognition

Source: Internet
Author: User

1. Watin Native identification element correspondence table

2, the corresponding configuration in the source code

In Watin, a class can correspond to more than one type in the HTML, such as the TextField class can recognize tagename in HTML as input and textarea, and can be set to identify the type attribute in the input tag.

3. Attribute acquisition in HTML markup

Some common parameters are defined in the HTML element class in Watin, such as Id, Name, InnerHtml, outerHTML, Outertext, tagname, and so on, and custom properties can also be obtained through the Getattributevalue function.

Cases:

HTML content

1 <HTML>2 <Head>3     <MetaCharSet= "Utf-8">4     <title>Watin test Page</title>5 </Head>6 <Body>7     <inputID= "Text1"type= "text"value= "literal text"Customatt= "Text 1" />8     <inputID= "Text2"type= "Password"value= "Password"Customatt= "Text 2" />9     <inputID= "Text3"type= "textarea"value= "Text textarea"Customatt= "Text 3" />Ten     <inputID= "Text4"type= "hidden"value= "Text hidden"Customatt= "Text 4" /> One     <textareaID= "Text5"Customatt= "Text 5">Text field</textarea> A </Body> - </HTML>

C # code

1  Public Static voidTest ()2 {3     //Get IE browser4ie ie = ie. Internetexplorers (). FirstOrDefault (p = p.title! =NULL&& P.title = ="watin test Page");5StringBuilder msg =NewSystem.Text.StringBuilder ();6     stringFormatstr ="id:{0}, Type:{1}, value:{2}, customatt:{3}";7     foreach(TextField Iteminchie. Textfields)8     {9         //Get text box/field property valueTenMsg. Appendline (string. Format (Formatstr, OneItem. Gdb//Get ID Property value AItem. Getattributevalue ("type"),//get the Type property value -Item. Text,//Get display text -Item. Getattributevalue ("Customatt")//Get custom property values the             )); -     } - System.Windows.Forms.MessageBox.Show (Msg. ToString ()); -}

Execution results

watin-html element and element attribute recognition

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.