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.