public void GenerateElemIDFile() { // First we build the list of FindParam objects we want serialized // and add them to a FindParamCollection object. HtmlFindExpression param1 = new HtmlFindExpression("TagIndex=table:0"); HtmlFindExpression param2 = new HtmlFindExpression("TextContent=~test1", "class=mystyle"); HtmlFindExpression param3 = new HtmlFindExpression("id=input1"); // Now add each FindParam defined above to the FindParamCollection // and give it a key that you can use to access it with later on. FindExpressionCollection <HtmlFindExpression> paramCol = new FindExpressionCollection <HtmlFindExpression>(); paramCol.Add("DataTable", param1); paramCol.Add("TargetDataCell", param2); paramCol.Add("InputTextBox", param3); // Now you can serialize this list to a string or a file // you can store with the test code. paramCol.Save("C:\\AppParams.xml"); // Or you can serialize to a string to be stored // in your choice of storage medium. // //Dim serializedParams As String = paramCol.ToXml() }
public void UsingLoadFromFile() { // Given we already have a datasource of FindExpression's stored on a different medium, // we can deserialize the data back into a FindExpressionCollection object and then // select one of these FindExpression's to locate a specific element on the page // like this: FindExpressionCollection <HtmlFindExpression> exprColl = FindExpressionCollection <HtmlFindExpression> .LoadFromFile(Path.Combine(TestContext.TestDir, @"..\..\SupportFiles\FindElementsFromFile.xml")); Assert.IsTrue(exprColl.Count == 2); Assert.IsTrue(this.Find.ByExpression(exprColl["MainTable1"]).ElementType == ElementType.Table); Assert.IsTrue(this.Find.ByExpression(exprColl["ProgramsTable"]).ElementType == ElementType.Table); }