本文整理汇总了C#中IHTMLElement.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IHTMLElement.GetType方法的具体用法?C# IHTMLElement.GetType怎么用?C# IHTMLElement.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHTMLElement
的用法示例。
在下文中一共展示了IHTMLElement.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetWindowProperties
public void SetWindowProperties(WatinScript watscript, string BrowserName, IHTMLElement element)
{
wscript = watscript;
browsername = BrowserName;
currentelement = element;
this.Text = string.Format(Properties.Resources.FunctionExplorer,element.GetType().ToString());
IHTMLDOMNode node = element as IHTMLDOMNode;
lbAttributes.Items.Clear();
lbAttributes.Items.Add(string.Format("tagName={0}",element.tagName), false);
string strValue = "";
string strFindMethod = wscript.GetFindMethod(element, ref strValue);
foreach (IHTMLDOMAttribute attr in node.attributes)
{
if (attr.specified)
{
if (strFindMethod.ToLower()==attr.nodeName.ToLower())
{
lbAttributes.Items.Add(attr.nodeName + "=" + attr.nodeValue, true);
}
else
{
lbAttributes.Items.Add(attr.nodeName + "=" + attr.nodeValue, false);
}
}
}
lbAttributes.Items.Add("innerHTML="+element.innerHTML, false);
if (strFindMethod=="innertext")
{
lbAttributes.Items.Add("innerText=" + element.innerText, true);
}
else
{
lbAttributes.Items.Add("innerText=" + element.innerText, false);
}
lbAttributes.Items.Add("outerHTML=" + element.outerHTML, false);
lbAttributes.Items.Add("outerText=" + element.outerText, false);
json = CreateJSONData(element);
LoadTabs(element);
}
示例2: getFirstValidSelectionElement
private IHTMLElement getFirstValidSelectionElement(IHTMLElement intialElement)
{
// Recursively expand the element outward until a valid containing element is
// found. If none is found, return null.
if (Array.IndexOf(this.validSelectionElementClassNames(), intialElement.GetType().Name) >= 0)
{
// This current element is valid as a container for an anchor element:
return intialElement;
}
else
{
/*
* The current element is not a valid container, but may be the
* child of either an anchor, or a valid anchor container:
*/
if (Array.IndexOf(this.CheckParentSelectionElementClassNames(), intialElement.GetType().Name) >= 0)
{
IHTMLElement parent = intialElement.parentElement;
// If the parent belongs to either group, recurse:
if (Array.IndexOf(this.validSelectionElementClassNames(), parent.GetType().Name) >= 0
|| Array.IndexOf(this.CheckParentSelectionElementClassNames(), parent.GetType().Name) >= 0)
{
return this.getFirstValidSelectionElement(parent);
}
else
{
// Otherise, return what we have (which may be invalid)
return intialElement;
}
}
else
{
// Nothing was found to be a valid anchor container:
return null;
}
}
}
示例3: getAnchorFromSelection
/// <summary>
/// Returns an anchor element if one is contained within the element passed in. otherwise returns null.
/// </summary>
/// <param name="initialElement"></param>
/// <returns></returns>
private IHTMLElement getAnchorFromSelection(IHTMLElement initialElement)
{
if (initialElement.GetType().Name == "HTMLAnchorElementClass")
{
return initialElement;
}
else
{
// See if the current element is potentially a child within an anchor element:
if (Array.IndexOf(this.CheckParentSelectionElementClassNames(), initialElement.GetType().Name) >= 0)
{
IHTMLElement parent = initialElement.parentElement;
// The parent of the current element may be an anchor, or may itself be a child of an anchor:
if (parent.GetType().Name == "HTMLAnchorElementClass"
|| Array.IndexOf(this.CheckParentSelectionElementClassNames(), parent.GetType().Name) >= 0)
{
return this.getAnchorFromSelection(parent);
}
else
{
return null;
}
}
else
{
return null;
}
}
}
示例4: SetWindowProperties
public void SetWindowProperties(WatinScript watscript, string BrowserName, IHTMLElement element)
{
tabControl1.SelectedTab = pageMethods;
wscript = watscript;
browsername = BrowserName;
currentelement = element;
this.Text = "Property Explorer - " + element.GetType().ToString();
IHTMLDOMNode node = element as IHTMLDOMNode;
gridProperties.Rows.Add("tagName", element.tagName);
foreach (IHTMLDOMAttribute attr in node.attributes)
{
if (attr.specified)
{
gridProperties.Rows.Add(attr.nodeName, attr.nodeValue);
}
}
gridProperties.Rows.Add("innerHTML", element.innerHTML);
gridProperties.Rows.Add("innerText", element.innerText);
gridProperties.Rows.Add("outerHTML", element.outerHTML);
gridProperties.Rows.Add("outerText", element.outerText);
rbSelectByText.Enabled = false;
comboSelectByText.Enabled = false;
rbSelectByValue.Enabled = false;
comboSelectByValue.Enabled = false;
rbSetFilename.Enabled = false;
txtSetFilename.Enabled = false;
btnSetFilename.Enabled = false;
rbChecked.Enabled = false;
rbUnchecked.Enabled = false;
string tagtype = watscript.ActiveElementAttribute(element, "type").ToLower();
if (element.tagName.ToLower() == "input" && tagtype == "file")
{
rbSetFilename.Enabled = true;
txtSetFilename.Enabled = true;
btnSetFilename.Enabled = true;
}
else if (element.tagName.ToLower() == "input" && (tagtype == "radio" || tagtype == "checkbox"))
{
rbChecked.Enabled = true;
rbUnchecked.Enabled = true;
}
else if (element.tagName.ToLower() == "select")
{
rbSelectByText.Enabled = true;
comboSelectByText.Enabled = true;
rbSelectByValue.Enabled = true;
comboSelectByValue.Enabled = true;
comboSelectByText.Items.Clear();
comboSelectByValue.Items.Clear();
mshtml.IHTMLSelectElement sel = element as mshtml.IHTMLSelectElement;
if (sel==null)
{
return;
}
for (int i = 0; i < sel.length; i++)
{
mshtml.IHTMLOptionElement op = sel.item(i, i) as mshtml.IHTMLOptionElement;
comboSelectByText.Items.Add(op.text);
if (op.value==null)
{
comboSelectByText.Items.Add(op.text);
}
else
{
comboSelectByValue.Items.Add(op.value);
}
}
}
}