internal static IRecordedCodeSequence RecordWebItem( TranscriptCmdletBase cmdlet, IRecordedCodeSequence codeSequence, IWebElement resultWebElement, RecordedWebElement elementItem) { if (null == codeSequence) { codeSequence = new RecordedCodeSequence(); } if (null == resultWebElement) { return(codeSequence); } try { // the previous code sequence should be added to the collection // any new web element must start with new code line if (0 < codeSequence.Items.Count) { codeSequence.ReadyToProduceCode = true; StoreCodeSequenceInCollection( cmdlet, RecordingCollection, codeSequence); codeSequence = new RecordedCodeSequence(); } elementItem = new RecordedWebElement(); elementItem.UserData.Add("Displayed", resultWebElement.Displayed); elementItem.UserData.Add("Enabled", resultWebElement.Enabled); elementItem.UserData.Add("Location", resultWebElement.Location); elementItem.UserData.Add("Selected", resultWebElement.Selected); elementItem.UserData.Add("Size", resultWebElement.Size); elementItem.UserData.Add("TagName", resultWebElement.TagName); elementItem.UserData.Add("Text", resultWebElement.Text); elementItem.UserData.Add("code", CodeGenGetElement); // temporarily or not //elementItem.Id = resultWebElement.GetAttribute("id"); //elementItem.Name = resultWebElement.GetAttribute("name"); //elementItem.ClassName = resultWebElement.GetAttribute("class"); // CSS // XPath // 20121031 - not here !!! elementItem.Final = false; //elementItem.ItemType = RecordingTypes.Element; elementItem.Root = true; // ?? codeSequence.Items.Add(elementItem); // 20121031 } catch (Exception eElementItem) { Console.WriteLine("not a fake item exception: " + eElementItem.Message); } return(codeSequence); }
internal static IRecordedCodeSequence RecordCodeSequence( TranscriptCmdletBase cmdlet, List <IRecordedCodeSequence> recordingCollection, object resultElement, IRecordedCodeSequence codeSequence) { RecordedWebElement elementItem = null; RecordedAction actionItem = null; RecordedData dataItem = null; var resultWebElement = resultElement as IWebElement; //RecordedData resultDataCollection = // resultElement as RecordedData; var resultDataCollection = resultElement as ReadOnlyCollection <object>; if (null == codeSequence) { codeSequence = new RecordedCodeSequence(); } if (null == resultElement) { return(codeSequence); } //Console.WriteLine(@"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ resultElement.GetType().Name = " + resultElement.GetType().Name); if (null != resultWebElement) { if (IsNotFakeWebElement(resultWebElement)) { codeSequence = RecordWebItem(cmdlet, codeSequence, resultWebElement, elementItem); } else // if (Recorder.isNotFakeWebElement(resultWebElement)) { { codeSequence = RecordActionItem(cmdlet, codeSequence, resultWebElement, actionItem); } // else } if (null != resultDataCollection) { Console.WriteLine(@"////////////////////////////////////////////////////////// null != resultDataCollection " + resultDataCollection.GetType().Name); codeSequence = RecordDataItem(cmdlet, codeSequence, resultDataCollection, dataItem); } cmdlet.WriteVerbose(cmdlet, "RecordCodeSequence"); return(codeSequence); }
private IRecordedCodeSequence generateWebItem( IRecordedCodeSequence codeSequence, IWebElement webElement, RecordedWebElement recordingItem) { IRecordedCodeSequence result = Recorder.RecordWebItem( (new TranscriptCmdletBase()), codeSequence, webElement, recordingItem); return result; }
internal static IRecordedCodeSequence RecordWebItem( TranscriptCmdletBase cmdlet, IRecordedCodeSequence codeSequence, IWebElement resultWebElement, RecordedWebElement elementItem) { if (null == codeSequence) { codeSequence = new RecordedCodeSequence(); } if (null == resultWebElement) { return codeSequence; } try { // the previous code sequence should be added to the collection // any new web element must start with new code line if (0 < codeSequence.Items.Count) { codeSequence.ReadyToProduceCode = true; Recorder.StoreCodeSequenceInCollection( cmdlet, recordingCollection, codeSequence); codeSequence = new RecordedCodeSequence(); } elementItem = new RecordedWebElement(); elementItem.UserData.Add("Displayed", resultWebElement.Displayed); elementItem.UserData.Add("Enabled", resultWebElement.Enabled); elementItem.UserData.Add("Location", resultWebElement.Location); elementItem.UserData.Add("Selected", resultWebElement.Selected); elementItem.UserData.Add("Size", resultWebElement.Size); elementItem.UserData.Add("TagName", resultWebElement.TagName); elementItem.UserData.Add("Text", resultWebElement.Text); elementItem.UserData.Add("code", codeGenGetElement); // temporarily or not //elementItem.Id = resultWebElement.GetAttribute("id"); //elementItem.Name = resultWebElement.GetAttribute("name"); //elementItem.ClassName = resultWebElement.GetAttribute("class"); // CSS // XPath // 20121031 - not here !!! elementItem.Final = false; //elementItem.ItemType = RecordingTypes.Element; elementItem.Root = true; // ?? codeSequence.Items.Add(elementItem); // 20121031 } catch (Exception eElementItem) { Console.WriteLine("not a fake item exception: " + eElementItem.Message); } return codeSequence; }
public void CheckCodeSequenceNovelty_CodeSequence_Duplicated() { bool result = false; bool expectedResult = false; TranscriptCmdletBase cmdlet = new TranscriptCmdletBase(); Recorder.RecordingCollection = new System.Collections.Generic.List<IRecordedCodeSequence>(); IRecordedCodeSequence codeSequence = new RecordedCodeSequence(); RecordedWebElement webElement = new RecordedWebElement(); webElement.TagName = "button"; codeSequence.Items.Add(webElement); RecordedAction action = new RecordedAction(); action.UserData.Add("code", Recorder.CodeGenElementClick); codeSequence.Items.Add(action); Recorder.RecordingCollection.Add(codeSequence); // a new code sequence codeSequence = new RecordedCodeSequence(); webElement = new RecordedWebElement(); webElement.TagName = "button"; codeSequence.Items.Add(webElement); action = new RecordedAction(); action.UserData.Add("code", Recorder.CodeGenElementClick); codeSequence.Items.Add(action); result = Recorder.CheckCodeSequenceNovelty( cmdlet, Recorder.RecordingCollection, codeSequence); Assert.AreEqual(expectedResult, result); }
public void RecordedWebElement_Constructor() { RecordedWebElement recAction = new RecordedWebElement(); //NUnit.Framework.Assert.NotNull(recAction.UserData); Assert.IsNotNull(recAction.UserData); }