ZennoLab Assemblies Documentation
FindElementByAttribute Method (Document)
Example 
ZennoLab.CommandCenter Namespace > Document Class : FindElementByAttribute Method

Type: System.String

Tags for search the element. If the count of tags is more than one then they are through ";".

Type: System.String

The attribute's name.

Type: System.String

The attribute's value.

Type: System.String

This parameter can take the following values​​: "text", "notext" and "regexp".

Type: System.Int32

The item number in a collection of matching items.

Searches for an element by the attribute, and returns the first occurrence.
Syntax

Parameters

tags

Type: System.String

Tags for search the element. If the count of tags is more than one then they are through ";".

attrName

Type: System.String

The attribute's name.

attrValue

Type: System.String

The attribute's value.

searchKind

Type: System.String

This parameter can take the following values​​: "text", "notext" and "regexp".

number

Type: System.Int32

The item number in a collection of matching items.

Return Value

Type: Zennolab.CommandCenter.HtmlElement

The first element that matches the conditions defined by the attribute, if found; otherwise, the result is void.

Remarks
If html element was not found then this method returns the HtmlElement object in which IsVoid or IsNill property is "true".
Example
The following code example demonstrates uses of the FindElementByAttribute method.
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
    // clear cookie
    instance.ClearCookie();
             
    // go to lessons.zennolab.com
    Tab tab = instance.MainTab;
    if ((tab.IsVoid) || (tab.IsNull)) return -1;
    if (tab.IsBusy) tab.WaitDownloading();
    tab.Navigate("lessons.zennolab.com", "");
    if (tab.IsBusy) tab.WaitDownloading();
            
    // find element using "text" parameter
    HtmlElement he = tab.MainDocument.FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
    if (he.IsVoid) return -1;
    // set value
    he.SetValue("True", instance.EmulationLevel, false);
            
    // find element using "regexp" parameter
    he = tab.MainDocument.FindElementByAttribute("input:radio", "fulltag", "input:radio", "regexp", 0);
    if (he.IsVoid) return -1;
    // set value
    he.SetValue("0", instance.EmulationLevel, false);
             
    // find element using "notext" parameter
    he = tab.MainDocument.FindElementByAttribute("textarea", "top", "288", "notext", 0);
    if (he.IsVoid) return -1;
    // set value
    he.SetValue("simple text", instance.EmulationLevel, false);
            
    return 0;
}
public static function Execute($instance, $project)
{
    // clear cookie
    $instance->ClearCookie();
             
    // go to lessons.zennolab.com
    $tab = $instance->MainTab;
    if (($tab->IsVoid) || ($tab->IsNull)) return -1;
    if ($tab->IsBusy) $tab->WaitDownloading();
    $tab->Navigate("lessons.zennolab.com", "");
    if ($tab->IsBusy) $tab->WaitDownloading();
            
    // find element using "text" parameter
    $he = $tab->MainDocument->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
    if ($he->IsVoid) return -1;
    // set value
    $he->SetValue("True", $instance->EmulationLevel, false);
            
    // find element using "regexp" parameter
    $he = $tab->MainDocument->FindElementByAttribute("input:radio", "fulltag", "input:radio", "regexp", 0);
    if ($he->IsVoid) return -1;
    // set value
    $he->SetValue("0", $instance->EmulationLevel, false);
             
    // find element using "notext" parameter
    $he = $tab->MainDocument->FindElementByAttribute("textarea", "top", "288", "notext", 0);
    if ($he->IsVoid) return -1;
    // set value
    $he->SetValue("simple text", $instance->EmulationLevel, false);
            
    return 0;
}
Requirements

Target Platforms: Desktop: Windows XP SP3 and older. Server: Windows Server 2003 and older.

See Also

Reference

Document Class
Document Members
FindElementById Method
FindElementByName Method
FindElementByTag Method
FindElementByXPath Method
FindElementsByAttribute Method
FindElementsById Method
FindElementsByName Method
FindElementsByTags Method
FindElementsByXPath Method
QuerySelector Method
QuerySelectorAll Method