A feasible selenium test framework

Source: Internet
Author: User
Tags bool xpath

I have long wanted to write some selenium test framework, but time and ideas are not very mature. Today, I would like to share with you roughly.

The background of this paper assumes that the reader has a certain experience in selenium use.

1. Element positioning

As you all know, the Web page this thing in the browser is a complete XML, so you can access the XML through the way, string query, regular, etc. to access the XML.

The traversal modes supported by Selenium are:

public class by {protected by (); protected by (Func<isearchcontext, iwebelement> Findelementmethod, Func<isearchcontext, ReadOnlyCollection
    
        <IWebElement>> Findelementsmethod);
        public static bool operator!= (by one, by two);
    
        public static BOOL operator = = (by one, by two);
        Protected string Description {get; set;}
        Protected Func<isearchcontext, iwebelement> findelementmethod {get; set;}
    
        Protected Func<isearchcontext, readonlycollection<iwebelement>> findelementsmethod {get; set;}
        public static by ClassName (string classnametofind);
        public static by Cssselector (string cssselectortofind);
        public override bool Equals (object obj);
        Public virtual Iwebelement findelement (isearchcontext context);
        Public virtual readonlycollection<iwebelement> findelements (isearchcontext context);
        public override int GetHashCode (); Public Static by Id (string idtofind);
        public static by LinkText (string linktexttofind);
        public static by Name (string nametofind);
        public static by Partiallinktext (string partiallinktexttofind);
        public static by TagName (string tagnametofind);
        public override string ToString ();
    public static by XPath (string xpathtofind); }

You can see that the last one is through XPath, and other estimates, such as Classname,cssselector, are also implemented through XPath. We can go to a specific look at the Webdrvier implementation of the source code, verify the thought, if the follow-up have time, I will dissect the source of Webdriver.

Well, with XPath, you can locate the elements on the page.

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.