private void btnAdd_Click(object sender, EventArgs e) { if (m_Selector.SelectedElements.Count > 0) { foreach (HtmlElement element in m_Selector.SelectedElements) { ElementIdentifier elementIdentifier = ElementIdentifier.FromHtmlElement(element); m_ElementIdentifiers.Add(elementIdentifier); } m_Selector.ClearSelection(); zRefreshList(); } else { ElementIdentifier elementIdentifier = new ElementIdentifier(); using (frmElementIdentifierEditor frm = new frmElementIdentifierEditor(elementIdentifier)) { if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { m_ElementIdentifiers.Add(elementIdentifier); zRefreshList(); } } } }
public void BuildEditItemUrl_EmptyElements_ThrowsException() { var elements = new ElementIdentifier[0]; var underTest = new EditLinkBuilder(DefaultOptions); Assert.Throws <ArgumentException>(() => underTest.BuildEditItemUrl(_language, elements)); }
private XElement zGetNormalizedDataSelector(GetValueStep getValueStep, ElementIdentifier templateSelectorIdentifier) { string selectPath = zGetSelectPathForGetValueStep(getValueStep, templateSelectorIdentifier); XElement defaultSelector = getValueStep.UseNormalizationDefault ? new XElement(xsl + "text", getValueStep.NormalizationDefault) : new XElement(xsl + "value-of", new XAttribute("select", selectPath)); if (getValueStep.NormalizationRules.Count > 0) { XElement choose = new XElement(xsl + "choose"); foreach (GetValueNormalizationRule normalizationRule in getValueStep.NormalizationRules) { choose.Add(new XElement(xsl + "when", new XAttribute("test", zGetNormalizationRuleTestCondition(normalizationRule, selectPath)), new XElement(xsl + "text", normalizationRule.ReplacementValue))); } choose.Add(new XElement(xsl + "otherwise", defaultSelector)); return(choose); } else { return(defaultSelector); } }
private string zGetRelativeSelectorPathForXSLT(ElementIdentifier baseIdentifier, ElementIdentifier targetIdentifier) { string selectPath = String.Empty; if (targetIdentifier != null) { if (baseIdentifier != null) { targetIdentifier = targetIdentifier.RelativeTo(baseIdentifier); } if (targetIdentifier.PrimaryIdentifier != null) { selectPath = targetIdentifier.PrimaryIdentifier.Replace('"', '\''); //Strip out tbody tags from path... they are not supported in the XML transformation of the DOM. selectPath = Regex.Replace(selectPath, "/?/?tbody[^/]*", String.Empty, RegexOptions.IgnoreCase); if (baseIdentifier != null && selectPath.StartsWith("/")) { selectPath = selectPath.Remove(0, 1); } } } return(selectPath); }
public void ElementIdentifier_AllDataProvided_GetsInstance() { var result = new ElementIdentifier(_itemId, _elementId); Assert.Equal(_itemId, result.ItemId); Assert.Equal(_elementId, result.ElementCodename); }
private void btnRemoveSelector_Click(object sender, EventArgs e) { ElementIdentifier elementIdentifier = (ElementIdentifier)olvElementIdentifiers.SelectedObject; ElementIdentifier nonAbsolute = elementIdentifier.RemoveSelector(); m_ElementIdentifiers.Add(nonAbsolute); zRefreshList(); }
private void btnParent_Click(object sender, EventArgs e) { ElementIdentifier elementIdentifier = (ElementIdentifier)olvElementIdentifiers.SelectedObject; ElementIdentifier parent = elementIdentifier.GetParent(); m_ElementIdentifiers.Add(parent); zRefreshList(); }
void m_Selector_ElementHighlighted(object sender, ElementSelectorEventArgs e) { if (e.FromUserAction) { ElementIdentifier identifier = ElementIdentifier.FromHtmlElement(e.Element); gbBrowser.Text = identifier.PrimaryIdentifier; } }
private void btnAbsolute_Click(object sender, EventArgs e) { ElementIdentifier baseElement = (ElementIdentifier)olvElementIdentifiers.SelectedObjects[0]; ElementIdentifier targetElement = (ElementIdentifier)olvElementIdentifiers.SelectedObjects[1]; ElementIdentifier absolute = targetElement.AbsoluteTo(baseElement); m_ElementIdentifiers.Add(absolute); zRefreshList(); }
private void btnRelative_Click(object sender, EventArgs e) { ElementIdentifier baseElement = (ElementIdentifier)olvElementIdentifiers.SelectedObjects[0]; ElementIdentifier targetElement = (ElementIdentifier)olvElementIdentifiers.SelectedObjects[1]; ElementIdentifier relative = targetElement.RelativeTo(baseElement); m_ElementIdentifiers.Add(relative); zRefreshList(); }
void m_ContainerSelector_ElementSelected(object sender, ElementSelectorEventArgs e) { if (e.FromUserAction) { m_ContainerIdentifier = ElementIdentifier.FromHtmlElement(e.Element).RemoveSelector(); zElementSelected(); zPreview(); } }
private string zGetSelectPathForGetValueStep(GetValueStep getValueStep, ElementIdentifier templateSelectorIdentifier) { string selectPath = zGetRelativeSelectorPathForXSLT(templateSelectorIdentifier, getValueStep.Element); if (getValueStep.Mode == ElementValueMode.Attribute && !String.IsNullOrEmpty(getValueStep.AttributeName)) { selectPath = String.Format("{0}/@{1}", selectPath, getValueStep.AttributeName); } return(selectPath); }
void m_ContainerSelector_ElementUnselected(object sender, ElementSelectorEventArgs e) { if (e.FromUserAction) { m_ContainerIdentifier = null; txtElementSetContainer.Text = String.Empty; btnSelect.Enabled = false; zPreview(); } }
public void BuildEditItemUrl_SingleElement_ReturnsValidUrl() { var elementIdentifier = new ElementIdentifier(_itemId, "single-element-Codename"); var underTest = new EditLinkBuilder(DefaultOptions); var result = underTest.BuildEditItemUrl(_language, elementIdentifier); var expected = "https://app.kontent.ai/goto/edit-item/project/14dc0cf8-6cc1-4f20-8e2e-0b5edea89e43/variant-codename/some-Language-Codename/item/1cdaa8ef-cb2b-4f82-82e9-45467b2e01b9/element/single-element-Codename"; Assert.Equal(expected, result); }
private void btnSelect_Click(object sender, EventArgs e) { using (ElementSetEditor frmElementSetEditor = new ElementSetEditor(this.StepEditContext, m_ContainerIdentifier)) { if (frmElementSetEditor.ShowDialog() == DialogResult.OK) { m_ContainerIdentifier = frmElementSetEditor.ContainerIdentifier; txtElementSetContainer.Text = m_ContainerIdentifier.PrimaryIdentifier; btnEdit.Enabled = true; } } }
public void SetContext(ElementValueMode elementValueMode, ElementIdentifier elementIdentifier, string attributeName) { cbAttribute.DataSource = zGetAttributeOptions(elementIdentifier, attributeName); cbAttribute.SelectedIndex = 0; rbAttribute.Checked = elementValueMode == ElementValueMode.Attribute; rbInnerText.Checked = elementValueMode == ElementValueMode.InnerText; cbAttribute.Enabled = rbAttribute.Checked; if (rbAttribute.Checked && !String.IsNullOrWhiteSpace(attributeName)) { cbAttribute.Text = attributeName; } }
private ElementIdentifier zGetElementIdentifier() { ElementIdentifier elementIdentifier = null; if (CurrentScope.ElementSetContainerIdentifier != null) { elementIdentifier = m_Step.Element.RelativeTo(CurrentScope.ElementSetContainerIdentifier); } else { elementIdentifier = m_Step.Element; } return(elementIdentifier); }
public GetValueSuggestor(StepEditContext stepEditContext, ElementIdentifier elementIdentifier, ElementValueMode elementValueMode, string attributeName) : this() { m_StepEditContext = stepEditContext; GroupStep parentGroupStep = AutomationUtils.GetParentGroupStep(m_StepEditContext.Sequence, m_StepEditContext.Step); if (parentGroupStep != null && parentGroupStep.Iteration != null && parentGroupStep.Iteration is ElementSetIteration) { m_GroupStepEditContext = new StepEditContext(parentGroupStep, m_StepEditContext.Sequence, m_StepEditContext.StepIndex, m_StepEditContext.StateVariables); } m_ElementIdentifier = elementIdentifier; m_ElementValueMode = elementValueMode; m_AttributeName = attributeName; }
private ElementIdentifier zGetElementSetContainer(ElementSetIteration iteration) { ElementIdentifier containerIdentifier = null; if (CurrentScope.ElementSetContainerIdentifier != null) { containerIdentifier = iteration.ElementSetContainer.RelativeTo(CurrentScope.ElementSetContainerIdentifier); } else { containerIdentifier = iteration.ElementSetContainer; } return(containerIdentifier); }
public static IWebElement FindElementInPage(ElementIdentifier elementIdentifier, string value) { switch (elementIdentifier) { case ElementIdentifier.Id: { return(FindElementWithWaitUnditElementIsVisible(By.Id(value))); } case ElementIdentifier.XPath: { return(FindElementWithWaitUnditElementIsVisible(By.XPath(value))); } case ElementIdentifier.Name: { return(FindElementWithWaitUnditElementIsVisible(By.Name(value))); } case ElementIdentifier.ClassName: { return(FindElementWithWaitUnditElementIsVisible(By.ClassName(value))); } case ElementIdentifier.CssCelector: { return(FindElementWithWaitUnditElementIsVisible(By.CssSelector(value))); } case ElementIdentifier.LinkText: { return(FindElementWithWaitUnditElementIsVisible(By.LinkText(value))); } case ElementIdentifier.PartialLinkText: { return(FindElementWithWaitUnditElementIsVisible(By.PartialLinkText(value))); } case ElementIdentifier.TagName: { return(FindElementWithWaitUnditElementIsVisible(By.TagName(value))); } default: return(null); } }
void Document_MouseUp(object sender, HtmlElementEventArgs e) { if (!m_ElementSelector.IsActive) { HtmlElement element = wbRecorder.Document.GetElementFromPoint(e.ClientMousePosition); if (element != null) { ClickStep clickStep = new ClickStep() { ClickType = ClickType.Left, Element = ElementIdentifier.FromHtmlElement(element) }; zAddStep(clickStep); } } }
void element_OnChange(object sender, EventArgs e) { HtmlElement activeElement = wbRecorder.Document.ActiveElement; if (activeElement != null) { SetValueStep setValueStep = new SetValueStep() { Element = ElementIdentifier.FromHtmlElement(activeElement), Mode = ElementValueMode.Attribute, AttributeName = "value", Value = activeElement.GetAttribute("value") }; zAddStep(setValueStep); } }
private void zShowProjection() { m_BrowserHelper.PollElements(m_ContainerIdentifier, (containerElements) => { foreach (HtmlElement containerElement in containerElements) { zShowPatternElement(containerElement, false); foreach (ElementIdentifier patternIdentifier in m_Pattern) { ElementIdentifier relativePatternIdentifier = patternIdentifier.RelativeTo(m_ContainerIdentifier); HtmlElement patternElement = m_BrowserHelper.FindElement(relativePatternIdentifier, containerElement); zShowPatternElement(patternElement, true); } } }); }
private void olvElementIdentifiers_CellClick(object sender, BrightIdeasSoftware.CellClickEventArgs e) { if (e.ClickCount == 2) { ElementIdentifier elementIdentifier = (ElementIdentifier)e.Model; WebBrowserHelper wb = new WebBrowserHelper(webBrowser1, TimeSpan.FromSeconds(15)); List <HtmlElement> elements = wb.FindElements(elementIdentifier); foreach (HtmlElement element in elements) { if (!m_Selector.SelectedElements.Contains(element)) { m_Selector.SelectElement(element); } } } }
protected override void zExecuteStep() { ElementIdentifier elementIdentifier = zGetElementIdentifier(); ThreadingUtils.InvokeControlAction(m_Context.BrowserHelper.Browser, ctl => { if (m_Step.ElementType == ElementType.Static) { HtmlElement element = m_Context.BrowserHelper.FindElement(elementIdentifier, CurrentScope.ElementSetIteratorItem); zElementLocated(element); } else { m_Context.BrowserHelper.PollElement(elementIdentifier, CurrentScope.ElementSetIteratorItem, m_Step.PollingTimeout.Value, zElementLocated); } }); }
void m_ElementSelector_ElementSelected(object sender, ElementSelectorEventArgs e) { if (e.FromUserAction) { //TODO: refactor this so that code is not repeated. if (m_ElementSelectMode == ElementSelectMode.Get) { GetValueStep getValueStep = new GetValueStep() { StateVariable = zGenerateVariableName(), Element = ElementIdentifier.FromHtmlElement(e.Element), XMLFieldOutputMode = XMLFieldOutputMode.Attribute, PersistenceMode = PersistenceMode.None }; //Default mode & attribute based on tag type if (e.Element.TagName.ToLower() == "input") { getValueStep.Mode = ElementValueMode.Attribute; getValueStep.AttributeName = "value"; } else { getValueStep.Mode = ElementValueMode.InnerText; } zAddStep(getValueStep); } else { SetValueStep setValueStep = new SetValueStep() { Element = ElementIdentifier.FromHtmlElement(e.Element) }; //Default mode & attribute based on tag type if (e.Element.TagName.ToLower() == "input") { setValueStep.Mode = ElementValueMode.Attribute; setValueStep.AttributeName = "value"; } else { setValueStep.Mode = ElementValueMode.InnerText; } zAddStep(setValueStep); } } }
public NodeElement ToElement(ElementIdentifier identifier) { var childs = new List <Element> { new ValueElement(new ElementIdentifier(TagProjectTypeGuid), this.ProjectTypeGuid), new ValueElement(new ElementIdentifier(TagProjectName), this.ProjectName), new ValueElement(new ElementIdentifier(TagRelativePath), this.RelativePath) }; if (this.ParentFolder != null) { childs.Add(new ValueElement( new ElementIdentifier(TagParentFolder), this.ParentFolder.ProjectFullName)); } foreach (var projectSection in this.ProjectSections) { childs.Add( projectSection.ToElement( new ElementIdentifier( TagProjectSection + projectSection.Name, string.Format("{0} \"{1}\"", projectSection.SectionType, projectSection.Name)))); } foreach (var propertyLine in this.VersionControlLines) { childs.Add( new ValueElement( new ElementIdentifier( TagVersionControlLines + propertyLine.Name, @"VersionControlLine\" + propertyLine.Name), propertyLine.Value)); } foreach (var propertyLine in this.ProjectConfigurationPlatformsLines) { childs.Add( new ValueElement( new ElementIdentifier( TagProjectConfigurationPlatformsLines + propertyLine.Name, @"ProjectConfigurationPlatformsLine\" + propertyLine.Name), propertyLine.Value)); } return(new NodeElement( identifier, childs)); }
void m_AutomationEngine_ExecutionComplete(object sender, ExecutionCompleteEventArgs e) { m_AutomationEngine.ExecutionComplete -= m_AutomationEngine_ExecutionComplete; ElementIdentifier containerIdentifier = null; if (m_GroupStepEditContext != null) { GroupStep groupStep = (GroupStep)m_GroupStepEditContext.Step; containerIdentifier = ((ElementSetIteration)groupStep.Iteration).ElementSetContainer; } ThreadingUtils.InvokeControlAction(this, ctl => { zDetect(containerIdentifier); }); }
public override void SetContext(StepEditContext context) { base.SetContext(context); m_ElementIdentifier = Step.Element != null?ElementIdentifier.Copy(Step.Element) : new ElementIdentifier(); txtElementPath.Text = m_ElementIdentifier.PrimaryIdentifier; rbStaticElement.Checked = Step.ElementType == ElementType.Static; rbDynamicElement.Checked = Step.ElementType == ElementType.Dynamic; ipPollingTimeout.Enabled = rbDynamicElement.Checked; if (rbDynamicElement.Checked && Step.PollingTimeout != null) { ipPollingTimeout.SetValue(Step.PollingTimeout.Value); } else { ipPollingTimeout.SetValue(TimeSpan.FromSeconds(5)); } }
public NodeElement ToElement(ElementIdentifier identifier) { var childs = new List<Element>(); childs.Add(new ValueElement(new ElementIdentifier(TagSectionType), this.SectionType)); childs.Add(new ValueElement(new ElementIdentifier(TagStep), this.Step)); foreach (var propertyLine in this.PropertyLines) { var lineIdentifier = new ElementIdentifier( TagPropertyLines + propertyLine.Name, @"Line\" + propertyLine.Name); if ((r_name == "WebsiteProperties") && (propertyLine.Name == "ProjectReferences")) { childs.Add(new NodeElement(lineIdentifier, ConvertProjectReferencesValueToHashList(propertyLine.Value))); } else { childs.Add(new ValueElement(lineIdentifier, propertyLine.Value)); } } return new NodeElement(identifier, childs); }
private void zDetect(ElementIdentifier containerIdentifier) { if (containerIdentifier != null) { m_BrowserHelper.PollElements(containerIdentifier, (containerElements) => { foreach (HtmlElement containerElement in containerElements) { ElementIdentifier relativeIdentifier = m_ElementIdentifier.RelativeTo(containerIdentifier); HtmlElement stepElement = m_BrowserHelper.FindElement(relativeIdentifier, containerElement); if (stepElement != null) { string value = AutomationUtils.GetValueFromHtmlElement(stepElement, m_ElementValueMode, m_AttributeName); if (!String.IsNullOrEmpty(value)) { value = value.Trim(); if (!m_Results.Contains(value)) { m_Results.Add(value); } } } } zShow(); }); } else { m_BrowserHelper.PollElement(m_ElementIdentifier, (getValueElement) => { string value = AutomationUtils.GetValueFromHtmlElement(getValueElement, m_ElementValueMode, m_AttributeName); if (!String.IsNullOrEmpty(value)) { value = value.Trim(); m_Results.Add(value); } zShow(); }); } }
public NodeConflict Validate(out List<string> messages) { // TODO Finish this. messages = new List<string>(); var projectsByFullName = new Dictionary<string, Project>(StringComparer.InvariantCultureIgnoreCase); var acceptedDifferences = new List<Difference>(); var conflicts = new List<Conflict>(); foreach (var project in this.Projects) { Project otherProject; if (projectsByFullName.TryGetValue(project.ProjectFullName, out otherProject)) { acceptedDifferences.Add( new NodeDifference( new ElementIdentifier( TagProject + project.ProjectGuid, string.Format("Project \"{0}\" [{1}]", project.ProjectFullName, project.ProjectGuid)), OperationOnParent.Removed, null)); var otherProjectIdentifier = new ElementIdentifier( TagProject + otherProject.ProjectGuid, string.Format("Project \"{0}\" [{1}]", otherProject.ProjectFullName, otherProject.ProjectGuid)); conflicts.Add( Conflict.Merge( new NodeElement(otherProjectIdentifier, null), otherProject.ToElement(otherProjectIdentifier), project.ToElement(otherProjectIdentifier))); } else { projectsByFullName.Add(project.ProjectFullName, project); } } return new NodeConflict(new ElementIdentifier("SolutionFile"), OperationOnParent.Modified, acceptedDifferences, conflicts); }
public NodeElement ToElement(ElementIdentifier identifier) { var childs = new List<Element> { new ValueElement(new ElementIdentifier(TagProjectTypeGuid), this.ProjectTypeGuid), new ValueElement(new ElementIdentifier(TagProjectName), this.ProjectName), new ValueElement(new ElementIdentifier(TagRelativePath), this.RelativePath) }; if (this.ParentFolder != null) { childs.Add(new ValueElement( new ElementIdentifier(TagParentFolder), this.ParentFolder.ProjectFullName)); } foreach (var projectSection in this.ProjectSections) { childs.Add( projectSection.ToElement( new ElementIdentifier( TagProjectSection + projectSection.Name, string.Format("{0} \"{1}\"", projectSection.SectionType, projectSection.Name)))); } foreach (var propertyLine in this.VersionControlLines) { childs.Add( new ValueElement( new ElementIdentifier( TagVersionControlLines + propertyLine.Name, @"VersionControlLine\" + propertyLine.Name), propertyLine.Value)); } foreach (var propertyLine in this.ProjectConfigurationPlatformsLines) { childs.Add( new ValueElement( new ElementIdentifier( TagProjectConfigurationPlatformsLines + propertyLine.Name, @"ProjectConfigurationPlatformsLine\" + propertyLine.Name), propertyLine.Value)); } return new NodeElement( identifier, childs); }
protected Conflict(ElementIdentifier identifier) { r_identifier = identifier; }