HtmlElement
Assembly: ZennoLab.CommandCenter
Full name: ZennoLab.CommandCenter.HtmlElement
Kind: class
Represents an HTML element on a Web page. Contains the methods to search for html elements, gets or sets of values.
The HtmlElement class contain the properties such as ErrorDetected, IsNull and IsVoid. Their use necessary for the correct work of your code.
Properties
ErrorDetected
Property
bool ErrorDetected { get; }
Gets information about the error detected in the performance last command.
If the HtmlElement object does not indicate to the real html element of dom model when this property is true. Also objects of this class contains IsNull and IsVoid properties for identification of element’s existence. Almost all classes of ZennoLab.CommandCenter contains such properties. Use it for the correct execution of the code.
Example
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
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// if error detected then exit with -1
if (he.ErrorDetected) return -1;
return 0;
}Example2
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
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// if error detected then exit with -1
if ($he->ErrorDetected) return -1;
return 0;
}IsVoid
Property
bool IsVoid { get; }
Gets the specified html element is void or not.
Example
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 by attribute
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// if element is void then return -1
if (he.IsVoid) return -1;
return 0;
}Example2
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 by attribute
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// if element is void then return -1
if ($he->IsVoid) return -1;
return 0;
}ZP_ID
Property
int ZP_ID { get; }
Gets the ID which represents html element on the server.
It is used only for the technical purposes
ParentTab
Property
Tab ParentTab { get; }
Gets the parent tab.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get parent tab
Tab parentTab = he.ParentTab;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get parent tab
$parentTab = $he->ParentTab;ParentDocument
Property
Document ParentDocument { get; }
Gets the parent document.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get parent document
Document parentDocument = he.ParentDocument;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get parent document
$parentDocument = $he->ParentDocument;ParentElement
Property
HtmlElement ParentElement { get; }
Gets the parent element.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get parent element
HtmlElement parentElement = he.ParentElement;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get parent element
$parentElement = $he->ParentElement;ParentForm
Property
HtmlElement ParentForm { get; }
Gets the parent form.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get parent form
HtmlElement parentElement = he.ParentForm;Example2
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get parent form
$parentElement = $he->ParentForm;ParentBody
Property
HtmlElement ParentBody { get; }
Gets the parent body.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get parent body
HtmlElement parentBody = he.ParentBody;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get parent body
$parentBody = $he->ParentBody;ContentDocument
Property
Document ContentDocument { get; }
Gets the content document for frame/iframe element.
FirstChild
Property
HtmlElement FirstChild { get; }
Gets the first child element.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get first child
HtmlElement first = he.FirstChild;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get first child
$first = $he->FirstChild;LastChild
Property
HtmlElement LastChild { get; }
Gets the last child element.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get the last child
HtmlElement last = he.LastChild;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get the last child
$last = $he->LastChild;NextSibling
Property
HtmlElement NextSibling { get; }
Gets the next element.
If the next element to a higher level, then return null.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get next element
HtmlElement next = he.NextSibling;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get next element
$next = $he->NextSibling;PreviousSibling
Property
HtmlElement PreviousSibling { get; }
Gets the previous element.
If the previous element to a higher level, then return null.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get previous element
HtmlElement prevElement = he.PreviousSibling;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get previous element
$prevElement = $he->PreviousSibling;OuterHtml
Property
string OuterHtml { get; }
Gets the dom text of the html element.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get outer html
string domText = he.OuterHtml;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get outer html
$domText = $he->OuterHtml;InnerHtml
Property
string InnerHtml { get; }
Gets the html text inside the tag of the element.
Example
// find element
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get inner html
string innerHtml = he.InnerHtml;Example2
// find element
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get inner html
$innerHtml = $he->InnerHtml;InnerText
Property
string InnerText { get; }
Gets the text inside the tag of the element.
Example
// find element
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get inner text
string innerText = he.InnerText;Example2
// find element
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get inner text
$innerText = $he->InnerText;TagName
Property
string TagName { get; }
Gets the tag of the element.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get tag name
string tag = he.TagName;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get tag name
$tag = $he->TagName;FullTagName
Property
string FullTagName { get; }
Gets the full tag of the element.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get full tag name
string fullTagName = he.FullTagName;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get full tag name
$fullTagName = $he->FullTagName;Name
Property
string Name { get; }
Gets the name of the html element.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get name
string name = he.Name;Example2
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get name
string name = he.Name;Id
Property
string Id { get; }
Gets the ID of the element
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get id
string id = he.Id;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get id
$id = $he->Id;Height
Property
int Height { get; }
Gets the height of the html element.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get height
int height = he.Height;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get height
$height = $he->Height;Width
Property
int Width { get; }
Gets the width of the html element.
Example
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get width
int width = he.Width;Example2
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get width
$width = $he->Width;BoundingClientHeight
Property
int BoundingClientHeight { get; }
Gets the bounding client height of the html element.
BoundingClientWidth
Property
int BoundingClientWidth { get; }
Gets the bounding client width of the html element.
IsNull
Property
bool IsNull { get; }
Gets a value that indicates whether or not the value of the html element is null value.
Example
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 by attribute
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// if element is null then return -1
if (he.IsNull) return -1;
return 0;
}Example2
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 by attribute
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// if element is null then return -1
if ($he->IsNull) return -1;
return 0;
}DisplacementInTabWindow
Property
Point DisplacementInTabWindow { get; }
Gets the displacement of the upper left corner relative to the tab’s window.
Example
using System.Drawing;
...
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get displacement in tab window
Point point = he.DisplacementInTabWindow;Example2
use System\Drawing;
...
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get displacement in tab window
$point = $he->DisplacementInTabWindow;DisplacementInDocument
Property
Point DisplacementInDocument { get; }
Gets the displacement of the upper left corner relative to the parent document.
This property displays the coordinates relative to the parent document. These coordinates are not always equal DisplacementInTabWindow.
Example
using System.Drawing;
...
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get displacement in document
Point point = he.DisplacementInDocument;Example2
use System\Drawing;
...
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get displacement in document
$point = $he->DisplacementInDocument;DisplacementInBrowser
Property
Point DisplacementInBrowser { get; }
Gets the displacement of the upper left corner relative to the window top.
Example
using System.Drawing;
...
// find element
HtmlElement he = tab.GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get displacement in document
Point point = he.DisplacementInBrowser;Example2
use System\Drawing;
...
// find element
$he = $tab->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get displacement in document
$point = $he->DisplacementInBrowser;Methods
ScrollIntoView
Method
void ScrollIntoView()
The performs scroll the tab to the current html element.
This method performs only the scrolling to the current html element. It may need when necessary change the view of the tab and for example perform click by coordinates inside the tab using the Tab class methods.
Example
// navigate to lessons.zennolab.com
instance.ActiveTab.Navigate("lessons.zennolab.com", "");
// wait downloading
instance.ActiveTab.WaitDownloading();
// try find the html element
HtmlElement he = instance.ActiveTab.MainDocument.FindElementByAttribute("textarea", "name", "text", "text", 0);
// if html element was found
if (!he.IsVoid)
{
// scroll view of tab to the html element
he.ScrollIntoView();
// performs the click inside tab by coordinates
instance.ActiveTab.MouseClick(he.DisplacementInTabWindow.X + 10, he.DisplacementInTabWindow.Y + 10, "left", "click");
// send the text
instance.SendText("It's just example. If you see this text then all work correctly. Don't forget to buy one more ZennoPoster.", 75);
}Example2
// navigate to lessons.zennolab.com
$instance->ActiveTab->Navigate("lessons.zennolab.com", "");
// wait downloading
$instance->ActiveTab->WaitDownloading();
// try find the html element
$he = $instance->ActiveTab->MainDocument->FindElementByAttribute("textarea", "name", "text", "text", 0);
// if html element was found
if (!$he->IsVoid)
{
// scroll view of tab to the html element
$he->ScrollIntoView();
// performs the click inside tab by coordinates
$instance->ActiveTab->MouseClick($he->DisplacementInTabWindow->X + 10, $he->DisplacementInTabWindow->Y + 10, "left", "click");
// send the text
$instance->SendText("It's just example. If you see this text then all work correctly. Don't forget to buy one more ZennoPoster.", 75);
}DragDrop
Method
void DragDrop(HtmlElement element, int dragX, int dradY, int dropX, int dropY)
Performs the drag and drop events for specified elements.
In case there is any coordinate is -1, will be used the central position of the element on specified axis.
Parameters
| Type | Name | Description |
|---|---|---|
HtmlElement | element | The html element for drop event. |
int | dragX | The x coordinate inside element’s area for rise drag event. Default value is -1. |
int | dradY | The y coordinate inside element’s area for rise drag event. Default value is -1. |
int | dropX | The x coordinate inside element’s area for rise drop event. Default value is -1. |
int | dropY | The y coordinate inside element’s area for rise drop event. Default value is -1. |
Example
// find element fo drop event
HtmlElement dropHe = instance.ActiveTab.FindElementById("some_id");
// if element is exist
if (!dropHe.IsVoid)
{
// find element for drap event
HtmlElement dragHe = instance.ActiveTab.FindElementById("any_id");
// if element is exist
if (!dragHe.IsVoid)
{
// rise drag and drop events
// drop dropHe (rise event in position x = 10, y = 30) to the specified place (50, 50)
dragHe.DragDrop(dropHe, 10, 30, 50, 50);
}
}Example2
// find element fo drop event
$dropHe = $instance->ActiveTab->FindElementById("some_id");
// if element is exist
if (!$dropHe->IsVoid)
{
// find element for drap event
$dragHe = $instance->ActiveTab->FindElementById("any_id");
// if element is exist
if (!$dragHe->IsVoid)
{
// rise drag and drop events
// drop dropHe (rise event in position x = 10, y = 30) to the specified place (50, 50)
$dragHe->DragDrop($dropHe, 10, 30, 50, 50);
}
}DrawToBitmap
Method
string DrawToBitmap(bool isImage, string hash)
Supports rendering to the bitmap.
If the html element has the tag “img” and the method’s parameter is true, then this method executes faster.
Parameters
| Type | Name | Description |
|---|---|---|
bool | isImage | true if the tag of this of the element is “img”, otherwise, false. |
string | hash | The parameter use only in demo version. Default value is String.Empty. |
Returns: The image as a string value.
Example
// find element by attribute
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// draw to bitmap element, this element is not image and does not contain image
string toBitmap1 = he.DrawToBitmap(false);
// find element by attribute
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("a", "href", "http://lessons.zennolab.com/ru/index", "regexp", 0);
// draw to bitmap element, this element is image or contains image
string toBitmap2 = he.DrawToBitmap(true);Example2
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// draw to bitmap element, this element is not image and does not contain image
$toBitmap1 = $he->DrawToBitmap(false);
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("a", "href", "http://lessons.zennolab.com/ru/index", "regexp", 0);
// draw to bitmap element, this element is image or contains image
$toBitmap2 = $he->DrawToBitmap(true);DrawAsBitmap
Method
Bitmap DrawAsBitmap(bool isImage, string hash)
Supports rendering to the bitmap.
If the html element has the tag “img” and the method’s parameter is true, then this method executes faster.
Parameters
| Type | Name | Description |
|---|---|---|
bool | isImage | true if the tag of this of the element is “img”, otherwise, false. |
string | hash | The parameter use only in demo version. Default value is String.Empty. |
Returns: The image as a bitmap.
Example
// find element by attribute
var he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// draw to bitmap element, this element is not image and does not contain image
var toBitmap1 = he.DrawAsBitmap(false);
// find element by attribute
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("a", "href", "http://lessons.zennolab.com/ru/index", "regexp", 0);
// draw to bitmap element, this element is image or contains image
var toBitmap2 = he.DrawAsBitmap(true);Example2
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// draw to bitmap element, this element is not image and does not contain image
$toBitmap1 = $he->DrawAsBitmap(false);
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("a", "href", "http://lessons.zennolab.com/ru/index", "regexp", 0);
// draw to bitmap element, this element is image or contains image
$toBitmap2 = $he->DrawAsBitmap(true);DrawPartToBitmap
Method
string DrawPartToBitmap(int left, int top, int width, int height, bool isImage, string hash)
Supports rendering part of element to the bitmap.
If the html element has the tag “img” and the method’s parameter is true, then this method executes faster.
Parameters
| Type | Name | Description |
|---|---|---|
int | left | The distance, in pixels, between the left edge of the element and the left edge of its client area. |
int | top | The distance, in pixels, between the top edge of the element and the top edge of its client area. |
int | width | The width of the part. |
int | height | The height of the part. |
bool | isImage | true if the tag of this of the element is “img”, otherwise, false. |
string | hash | The parameter use only in demo version. Default value is String.Empty. |
Returns: The part of image as a string value.
Example
// find element by attribute
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("a", "href", "http://lessons.zennolab.com/ru/index", "regexp", 0);
// draw part of bitmap to the string value
string toBitmap = he.DrawPartToBitmap(0, 0, 20, 20, true);Example2
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("a", "href", "http://lessons.zennolab.com/ru/index", "regexp", 0);
// draw part of bitmap to the string value
$toBitmap = $he->DrawPartToBitmap(0, 0, 20, 20, true);DrawPartAsBitmap
Method
Bitmap DrawPartAsBitmap(int left, int top, int width, int height, bool isImage, string hash)
Supports rendering part of element to the bitmap.
If the html element has the tag “img” and the method’s parameter is true, then this method executes faster.
Parameters
| Type | Name | Description |
|---|---|---|
int | left | The distance, in pixels, between the left edge of the element and the left edge of its client area. |
int | top | The distance, in pixels, between the top edge of the element and the top edge of its client area. |
int | width | The width of the part. |
int | height | The height of the part. |
bool | isImage | true if the tag of this of the element is “img”, otherwise, false. |
string | hash | The parameter use only in demo version. Default value is String.Empty. |
Returns: The part of image as a bitmap.
Example
// find element by attribute
var he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("a", "href", "http://lessons.zennolab.com/ru/index", "regexp", 0);
// draw part of bitmap to the string value
var toBitmap = he.DrawPartAsBitmap(0, 0, 20, 20, true);Example2
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("a", "href", "http://lessons.zennolab.com/ru/index", "regexp", 0);
// draw part of bitmap to the string value
$toBitmap = $he->DrawPartAsBitmap(0, 0, 20, 20, true);FindChildByAttribute
Method
HtmlElement FindChildByAttribute(string tags, string attrName, string attrValue, string searchKind, int number)
Searches for an element among the children by the attribute, and returns the first occurrence.
If html element was not found then this method returns the HtmlElement object in which IsVoid or IsNill property is “true”.
Parameters
| Type | Name | Description |
|---|---|---|
string | tags | Tags for search the element. If the count of tags is more than one then they are through ”;“. |
string | attrName | The attribute name. |
string | attrValue | The attribute value. |
string | searchKind | This parameter can take the following values: “text”, “notext” and “regexp”. |
int | number | The document address. |
Returns: The first element that matches the conditions defined by the attribute, if found; otherwise, the result is void.
Example
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 by id
HtmlElement he = tab.FindElementById("main");
// find child element by attribute
HtmlElement heCh = he.FindChildByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
// find child element by attribute
$heCh = $he->FindChildByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
return 0;
}FindChildrenByAttribute
Method
HtmlElementCollection FindChildrenByAttribute(string tags, string attrName, string attrValue, string searchKind)
Searches for all elements among the children by the attribute.
If html elements were not found then this method returns the HtmlElementCollection object in which IsVoid property is “true”.
Parameters
| Type | Name | Description |
|---|---|---|
string | tags | Tags for search the elements. If the count of tags is more than one then they are through ”;“. |
string | attrName | The attribute name. |
string | attrValue | The attribute value. |
string | searchKind | This parameter can take the following values: “text”, “notext” and “regexp”. |
Returns: The collection of elements that matches the conditions defined by the attribute, if found; otherwise, the Count property is “0”.
Example
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 by id
HtmlElement he = tab.FindElementById("main");
// find all children by attribute
HtmlElementCollection heCol = he.FindChildrenByAttribute("input:checkbox", "fulltag", "input:checkbox", "text");
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
// find all children by attribute
$heCol = $he->FindChildrenByAttribute("input:checkbox", "fulltag", "input:checkbox", "text");
return 0;
}FindChildById
Method
HtmlElement FindChildById(string id)
Searches for an element among the children by the ID, and returns the first occurrence.
If html element was not found then this method returns the HtmlElement object in which IsVoid or IsNill property is “true”.
Parameters
| Type | Name | Description |
|---|---|---|
string | id | The ID that defines search condition of HTML elements. |
Returns: The first element that matches the conditions defined by the ID, if found; otherwise, the result is void.
Example
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 by id
HtmlElement he = tab.FindElementById("main");
// find child element by id
HtmlElement heCh = he.FindChildById("inputs");
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
// find child element by id
$heCh = $he->FindChildById("inputs");
return 0;
}FindChildrenById
Method
HtmlElementCollection FindChildrenById(string id)
Searches for all elements among the children by the ID.
If html elements were not found then this method returns the HtmlElementCollection object in which IsVoid property is “true”.
Parameters
| Type | Name | Description |
|---|---|---|
string | id | The ID that defines search condition of HTML elements. |
Returns: The collection of elements that matches the conditions defined by the ID, if found; otherwise, the Count property is “0”.
Example
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 by id
HtmlElement he = tab.FindElementById("main");
// find all children by id
HtmlElementCollection heCol = he.FindChildrenById("inputs");
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
// find all children by id
$heCol = $he->FindChildrenById("inputs");
return 0;
}FindChildByName
Method
HtmlElement FindChildByName(string name)
Searches for an element among the children by the name, and returns the first occurrence.
If html element was not found then this method returns the HtmlElement object in which IsVoid or IsNill property is “true”.
Parameters
| Type | Name | Description |
|---|---|---|
string | name | The name that defines search condition of HTML elements. |
Returns: The first element that matches the conditions defined by the name, if found; otherwise, the result is void.
Example
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 by id
HtmlElement he = tab.FindElementById("main");
// find child element by name
HtmlElement heCh = he.FindChildByName("text");
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
// find child element by name
$heCh = $he->FindChildByName("text");
return 0;
}FindChildrenByName
Method
HtmlElementCollection FindChildrenByName(string name)
Searches for all elements among the children by the name.
If html elements were not found then this method returns the HtmlElementCollection object in which IsVoid property is “true”.
Parameters
| Type | Name | Description |
|---|---|---|
string | name | The name that defines search condition of HTML elements. |
Returns: The collection of elements that matches the conditions defined by the name, if found; otherwise, the Count property is “0”.
Example
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 by id
HtmlElement he = tab.FindElementById("main");
// find all children by name
HtmlElementCollection heCol = he.FindChildrenByName("text");
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
// find all children by name
$heCol = $he->FindChildrenByName("text");
return 0;
}FindChildByTag
Method
HtmlElement FindChildByTag(string tag, int number)
Searches for an element among the children by the tag, and returns the first occurrence.
If html element was not found then this method returns the HtmlElement object in which IsVoid or IsNill property is “true”.
Parameters
| Type | Name | Description |
|---|---|---|
string | tag | Tag for search the element. |
int | number | The document address. |
Returns: The first element that matches the conditions defined by the tag, if found; otherwise, the result is void.
Example
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 by id
HtmlElement he = tab.FindElementById("main");
// find child element by tag
HtmlElement heCh = he.FindChildByTag("input:checkbox", 0);
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
// find child element by tag
$heCh = $he->FindChildByTag("input:checkbox", 0);
return 0;
}FindChildrenByTags
Method
HtmlElementCollection FindChildrenByTags(string tags)
Searches for all elements among the children by the tags.
If html elements were not found then this method returns the HtmlElementCollection object in which IsVoid property is “true”.
Parameters
| Type | Name | Description |
|---|---|---|
string | tags | Tags for search the elements. If the count of tags is more than one then they are through ”;“. |
Returns: The collection of elements that matches the conditions defined by the tags, if found; otherwise, the Count property is “0”.
Example
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 by id
HtmlElement he = tab.FindElementById("main");
// find all children by tag
HtmlElementCollection heCol = he.FindChildrenByTags("input:checkbox");
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
// find all children by tag
$heCol = $he->FindChildrenByTags("input:checkbox");
return 0;
}FindChildByXPath
Method
HtmlElement FindChildByXPath(string xpath, int number)
Searches for an element among the children by the xpath.
If html element was not found then this method returns the HtmlElement object in which IsVoid or IsNill property is “true”.
Parameters
| Type | Name | Description |
|---|---|---|
string | xpath | XPath for search the element. |
int | number | The document address. |
Returns: The first element that matches the conditions defined by the tag, if found; otherwise, the result is void.
Example
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 by id
HtmlElement he = tab.FindElementById("main");
if (he.IsVoid) return -2;
// find child element by xpath
HtmlElement heCh = he.FindChildByXPath("div[@id]", 0);
if (heCh.IsVoid) return -3;
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
if ($he->IsVoid) return -2;
// find child element by xpath
$heCh = $he->FindChildByXPath("div[@id]", 0);
if ($heCh->IsVoid) return -3;
return 0;
}FindChildrenByXPath
Method
HtmlElementCollection FindChildrenByXPath(string xpath)
Searches for all elements among the children by the xpath.
If html elements were not found then this method returns the HtmlElementCollection object in which IsVoid property is “true”.
Parameters
| Type | Name | Description |
|---|---|---|
string | xpath | XPath for search the elements. |
Returns: The collection of elements that matches the conditions defined by the tags, if found; otherwise, the Count property is “0”.
Example
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 by id
HtmlElement he = tab.FindElementById("main");
// find all children by xpath
HtmlElementCollection heCol = he.FindChildrenByXPath("div[@id]");
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
// find all children by xpath
$heCol = $he->FindChildrenByXPath("div[@id]");
return 0;
}GetChildren
Method
HtmlElementCollection GetChildren(bool recursive)
Returns the all children.
Parameters
| Type | Name | Description |
|---|---|---|
bool | recursive | true to returns all children of the element; otherwise, false, returns the children of the first level. |
Returns: A collection that contains all children of the html element.
Example
// find element by attribute
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get all children of current html element
HtmlElementCollection heCol = he.GetChildren(true);Example2
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get all children of current html element
$heCol = $he->GetChildren(true);RemoveChild
Method
void RemoveChild(HtmlElement child)
Removes a first level child element.
The IsNull property be true if the html element does not belongs to any document.
Parameters
| Type | Name | Description |
|---|---|---|
HtmlElement | child | The first level child element to remove. |
Example
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 by id
HtmlElement he = tab.FindElementById("main");
// find element for remove
HtmlElement heToRemove = tab.FindElementById("inputs");
// remove child element
he.RemoveChild(heToRemove);
return 0;
}Example2
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 by id
$he = $tab->FindElementById("main");
// find element for remove
$heToRemove = $tab->FindElementById("inputs");
// remove child element
$he->RemoveChild($heToRemove);
return 0;
}InsertElementBefore
Method
void InsertElementBefore(HtmlElement insertingElement)
Inserts the specified element before this element.
Parameters
| Type | Name | Description |
|---|---|---|
HtmlElement | insertingElement | The html element to insert. The value can be null. |
Example
// find first element
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// find second element
HtmlElement hePrev = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByName("rad");
// insert element "hePrev" before "he"
he.InsertElementBefore(hePrev);Example2
// find first element
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// find second element
$hePrev = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByName("rad");
// insert element "hePrev" before "he"
$he->InsertElementBefore($hePrev);InsertElementAfter
Method
void InsertElementAfter(HtmlElement insertingElement)
Inserts the specified element after this element.
Parameters
| Type | Name | Description |
|---|---|---|
HtmlElement | insertingElement | The html element to insert. The value can be null. |
Example
// find first element
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// find second element
HtmlElement heNext = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByName("rad");
// insert element "heNext" after "he"
he.InsertElementAfter(heNext);Example2
// find first element
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// find second element
$heNext = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByName("rad");
// insert element "heNext" after "he"
$he->InsertElementAfter($heNext);SetAttribute
Method
void SetAttribute(string attrName, string attrValue)
Sets the text of attribute.
Parameters
| Type | Name | Description |
|---|---|---|
string | attrName | The attribute name. |
string | attrValue | The new value for this attribute. |
Example
// find element
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// set attribute
he.SetAttribute("Name", "NewTextValue");Example2
// find element
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// set attribute
$he->SetAttribute("Name", "NewTextValue");GetAttribute
Method
string GetAttribute(string attrName)
Returns the text of attribute.
Parameters
| Type | Name | Description |
|---|---|---|
string | attrName | The name of attribute. |
Returns: The text of attribute.
Example
// find element by attribute
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get attribute value
string attributeText = he.GetAttribute("TagName");Example2
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get attribute value
$attributeText = $he->GetAttribute("TagName");GetStylePropertyValue
Method
string GetStylePropertyValue(string property)
Returns the text of style property.
Parameters
| Type | Name | Description |
|---|---|---|
string | property | The name of style property. |
Returns: The text of style property.
Example
// find element by attribute
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get attribute value
string propertyText = he.GetStylePropertyValue("display");
// propertyText = "inline-block"Example2
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get attribute value
$propertyText = $he->GetStylePropertyValue("display");
// $propertyText = "inline-block"RemoveAttribute
Method
void RemoveAttribute(string attrName)
Removes the specified attribute.
Parameters
| Type | Name | Description |
|---|---|---|
string | attrName | The name of the attribute. |
RiseEvent
Method
void RiseEvent(string eventName, string emulation)
The performs the specified event for html element.
The emulation levels: “Full” - the full emulation which include the generation of all events such as mouseover, mousemove, mouseout, focus on element and other.”Middle” - the standard emulation level includes a minimum of actions without additional events.”None” - the default emulation level without additional events and actions.
Parameters
| Type | Name | Description |
|---|---|---|
string | eventName | The name of the event. |
string | emulation | The emulation level. Can be: “None”, “Middle”, “Full” or “SuperEmulation”. |
Example
// find element
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// rise event
he.RiseEvent("onclick", "full");Example2
// find element
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// rise event
$he->RiseEvent("onclick", "full");ReplaceChild
Method
void ReplaceChild(HtmlElement newChild, HtmlElement oldChild)
Replaces the specified child element.
Parameters
| Type | Name | Description |
|---|---|---|
HtmlElement | newChild | The new child element. |
HtmlElement | oldChild | The old child element. |
Example
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
HtmlElement he = tab.FindElementById("main");
// find first element
HtmlElement heOld = tab.FindElementById("inputs");
// find second element
HtmlElement heNew = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("a", "href", "http://lessons.zennolab.com/ru/index", "regexp", 0);
// replace element "heOld" to "heNew"
he.ReplaceChild(heNew, heOld);
return 0;
}Example2
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
$he = $tab->FindElementById("main");
// find first element
$heOld = $tab->FindElementById("inputs");
// find second element
$heNew = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("a", "href", "http://lessons.zennolab.com/ru/index", "regexp", 0);
// replace element "heOld" to "heNew"
$he->ReplaceChild($heNew, $heOld);
return 0;
}GetValue
Method
string GetValue(bool useSelectedItems)
Returns the value of the html element.
Parameters
| Type | Name | Description |
|---|---|---|
bool | useSelectedItems | true for getting value using selected items; otherwise, false. |
Returns: The element value for the html element.
Example
// find html element
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get value
string heValue = he.GetValue(false);Example2
// find html element
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// get value
$heValue = $he->GetValue(false);SetValue
Method
void SetValue(string value, string emulation, bool useSelectedItems, bool append)
Sets the value of the html element.
Parameters
| Type | Name | Description |
|---|---|---|
string | value | The new value for this html element. |
string | emulation | The emulation level. May be: “None”, “Middle”, “Full” or “SuperEmulation”. |
bool | useSelectedItems | true if you need use automatic filling standard “select” fields; otherwise false. |
bool | append | true if you need append value to an existing content; otherwise false. |
Example
// find element
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// set value
he.SetValue("true", "Middle", true);Example2
// find element
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// set value
$he->SetValue("true", "Middle", true);GetSelectedItems
Method
string GetSelectedItems()
Returns the value of the selected items.
Returns: The value of the selected items recorded through ”;“.
Example
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 by name
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByName("lang[]");
if (he.IsVoid) return -1;
// set value
he.SetValue("1;2;3", true);
// get selected items in string format
string selectedItems = he.GetSelectedItems();
return 0;
}Example2
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 by name
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByName("lang[]");
if ($he->IsVoid) return -1;
// set value
$he->SetValue("1;2;3", true);
// get selected items in string format
$selectedItems = $he->GetSelectedItems();
return 0;
}SetSelectedItems
Method
void SetSelectedItems(string value)
Sets the value of the selected items.
Parameters
| Type | Name | Description |
|---|---|---|
string | value | The value of the selected items recorded through ”;“. |
Example
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
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByName("anything[]");
// set selected item
he.SetSelectedItems("16-30");
return 0;
}Example2
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
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByName("anything[]");
// set selected item
$he->SetSelectedItems("16-30");
return 0;
}Focus
Method
void Focus()
Sets input focus to the html element.
Example
// find element by attribute
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// focus on this element
he.Focus();Example2
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// focus on this element
$he->Focus();Click
Method
void Click()
The performs the click event on the html element.
This method performs the click event with default settings. For setting the event settings use the RiseEvent method.
Example
// find element by attribute
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// click on the element
he.Click();Example2
// find element by attribute
$he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
// click on the element
$he->Click();Reload
Method
void Reload()
Reloads the html element.
This method performs the reload the html element.
Example
// find flash objects
var flashObjects = instance.ActiveTab.FindElementsByTags("embed;object");
if (flashObjects == null) return -1;
// set wmode = opaque every element which has incorrect value of property "wmode"
for (int i = 0; i < flashObjects.Count; i++)
{
var flashObjectsNew = instance.ActiveTab.FindElementsByTags("embed;object");
var element = flashObjectsNew.GetByNumber(i);
var children = element.FindChildrenByName("wmode");
if (children != null && children.Count != 0) {
for (int j = 0; j < children.Count; j++)
{
var child = children.GetByNumber(j);
if (child.ParentElement.ZP_ID != element.ZP_ID)
continue;
if (child.TagName.ToLower().Equals("param"))
{
var wmode = child.GetAttribute("value");
if (wmode != null && (!wmode.ToLower().Equals("opaque") && !wmode.ToLower().Equals("transparent")))
{
child.SetAttribute("value", "opaque");
element.Reload();
}
}
}
}
else
{
var wmode = element.GetAttribute("wmode");
if (!(wmode != null && (wmode.ToLower().Equals("opaque") || wmode.ToLower().Equals("transparent"))))
{
element.SetAttribute("wmode", "opaque");
element.Reload();
}
}
}Example2
// find flash objects
$flashObjects = $instance->ActiveTab->FindElementsByTags("embed;object");
if ($flashObjects == null) return -1;
// set wmode = opaque every element which has incorrect value of property "wmode"
for ($i = 0; $i < $flashObjects->Count; i++)
{
$flashObjectsNew = $instance->ActiveTab->FindElementsByTags("embed;object");
$element = $flashObjectsNew->GetByNumber($i);
$children = $element->FindChildrenByName("wmode");
if ($children != null && $children->Count != 0) {
for ($j = 0; $j < $children->Count; j++)
{
$child = $children->GetByNumber($j);
if ($child->ParentElement->ZP_ID != $element->ZP_ID)
continue;
if ($child->TagName->ToLower()->Equals("param"))
{
$wmode = $child->GetAttribute("value");
if ($wmode != null && (!$wmode->ToLower()->Equals("opaque") && !$wmode->ToLower()->Equals("transparent")))
{
$child->SetAttribute("value", "opaque");
$element->Reload();
}
}
}
}
else
{
$wmode = $element->GetAttribute("wmode");
if (!($wmode != null && ($wmode->ToLower()->Equals("opaque") || $wmode->ToLower()->Equals("transparent"))))
{
$element->SetAttribute("wmode", "opaque");
$element->Reload();
}
}
}DropFile
Method
void DropFile(string filepath, int x, int y)
Drop file to the element.
Parameters
| Type | Name | Description |
|---|---|---|
string | filepath | The path to file. |
int | x | The x coordinate inside element’s area for rise drag event. Default value is -1. |
int | y | The y coordinate inside element’s area for rise drag event. Default value is -1. |