Tab
Assembly: ZennoLab.CommandCenter
Full name: ZennoLab.CommandCenter.Tab
Represents a tab of browser. Contains the necessary methods and properties for working with tabs instance.
The Tab class contain the properties such as ErrorDetected, IsBusy, IsNull and IsVoid. Their use necessary for the correct work of your code.
Properties
Name
Property
Gets the name of the tab.
Example
// get main tab
Tab tab = instance.MainTab;
// get name
string name = tab.Name;Example2
// get main tab
$tab = $instance->MainTab;
// get name
$domText = $tab->Name;IsVoid
Property
Gets the specified tab 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.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
return 0;
}ErrorDetected
Property
Gets information about the error detected in the performance last command.
If the Tab object does not indicate to the tab of instance when this property is true. Also objects of this class contains IsNull and IsVoid properties for identification of tab’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.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// if error detected the return -1
if (tab.ErrorDetected) return -1;
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// if error detected the return -1
if ($tab->ErrorDetected) return -1;
return 0;
}ZP_ID
Property
Gets the ID which represents tab on the server.
It is used only for the technical purposes
AllDocuments
Property
Gets the all uploaded documents.
Example
// get main tab
Tab tab = instance.MainTab;
// get all documents
DocumentCollection docCol = tab.AllDocuments;Example2
// get main tab
$tab = $instance->MainTab;
// get all documents
$docCol = $tab->AllDocuments;MainDocument
Property
Gets the main document the current tab.
Example
// get main tab
Tab tab = instance.MainTab;
// get main document
Document doc = tab.MainDocument;Example2
// get main tab
$tab = $instance->MainTab;
// get main document
$doc = $tab->MainDocument;MainBody
Property
Gets the main body of tab.
Example
// get main tab
Tab tab = instance.MainTab;
// get main body
HtmlElement he = tab.MainBody;Example2
// get main tab
$tab = $instance->MainTab;
// get main body
$he = $tab->MainBody;URL
Property
Gets the URL-address of the page the current tab.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// get url
string url = tab.URL;
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// get url
$url = $tab->URL;
return 0;
}Domain
Property
Gets the current domain of the tab.
Example
// get main tab
Tab tab = instance.MainTab;
// get domain
string domain = tab.Domain;Example2
// get main tab
$tab = $instance->MainTab;
// get domain
$domain = $tab->Domain;MainDomain
Property
Gets the current main domain of the tab.
Example
// get main tab
Tab tab = instance.MainTab;
// get main domain
string domain = tab.MainDomain;Example2
// get main tab
$tab = $instance->MainTab;
// get main domain
$domain = $tab->MainDomain;LastAlertTitle
Property
Gets the last alert title of the tab.
Example
// get main tab
Tab tab = instance.MainTab;
// get alert title
string alerttitle = tab.LastAlertTitle;Example2
// get main tab
$tab = $instance->MainTab;
// get alert title
$alerttitle = $tab->LastAlertTitle;LastAlertText
Property
Gets the last alert text of the tab.
Example
// get main tab
Tab tab = instance.MainTab;
// get alert message
string alerttext = tab.LastAlertText;Example2
// get main tab
$tab = $instance->MainTab;
// get alert message
$alerttext = $tab->LastAlertText;Title
Property
Gets the title of the tab.
Example
// get main tab
Tab tab = instance.MainTab;
// get title
string title = tab.Title;Example2
// get main tab
$tab = $instance->MainTab;
// get title
$title = $tab->Title;Handle
Property
Gets the handle of the browser window.
Example
// get main tab
Tab tab = instance.MainTab;
// get handle
int handle = tab.Handle;Example2
// get main tab
$tab = $instance->MainTab;
// get handle
$handle = $tab->Handle;IsBusy
Property
Gets the specified tab is busy or not.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
return 0;
}IsInteractive
Property
Gets the specified tab is interactive.
IsPreComplete
Property
Gets the specified tab is pre-complete.
IsNull
Property
Gets a value that indicates whether or not the value of the tab is null value.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
return 0;
}NavigateTimeout
Property
Gets or sets the timeout of page loading.
Example
// get main tab
Tab tab = instance.MainTab;
// get navigate timeout
int timeout = tab.NavigateTimeout;
// set navigate timeout
tab.NavigateTimeout = timeout*2;Example2
// get main tab
$tab = $instance->MainTab;
// get navigate timeout
$timeout = $tab->NavigateTimeout;
// set navigate timeout
$tab->NavigateTimeout = $timeout*2;DomText
Property
Gets the dom text of the tab.
Example
// get main tab
Tab tab = instance.MainTab;
// get dom text
string domText = tab.DomText;Example2
// get main tab
$tab = $instance->MainTab;
// get dom text
$domText = $tab->DomText;PageText
Property
Gets the text of the page that the user sees.
Example
// get main tab
Tab tab = instance.MainTab;
// get page text
string pageText = tab.PageText;Example2
// get main tab
$tab = $instance->MainTab;
// get page text
$pageText = $tab->PageText;MainPageArticle
Property
Gets the text of the main page article.
FullEmulationMouseCurrentPosition
Property
Gets or sets the current full emulation mouse coordinates.
Example
return instance.ActiveTab.FullEmulationMouseCurrentPosition;Example2
return instance->ActiveTab->FullEmulationMouseCurrentPosition;FullEmulationMouseTabPosition
Property
Gets or sets the current full emulation mouse coordinates in the window.
Example
return instance.ActiveTab.FullEmulationMouseTabPosition;Example2
return instance->ActiveTab->FullEmulationMouseTabPosition;NavigateErrorDetected
Property
Gets information about the error detected in the performance last navigation.
PageScale
Property
Gets or sets a value in percent that indicates scale of page.
Touch
Property
Contains methods simulating work with touch screen
Methods
WaitDownloading
Method
Waits downloading of the page.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
return 0;
}WaitInteractive
Method
Waits until the status changed to interactive.
WaitPreComplete
Method
Waits until the status changed to PreComplite.
Stop
Method
Stops downloading of the page.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// stop downloading
if (tab.IsBusy) tab.Stop();
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// stop downloading
if ($tab->IsBusy) $tab->Stop();
return 0;
}Navigate
Method
Navigates to a resource identified by a URL with specified referrer.
Parameters
| Параметр | Описание |
|---|---|
url | A string expression that evaluates to the URL. |
referrer | A string expression that evaluates to the HTTP_REFERER header. It is empty by default. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
return 0;
}GoBack
Method
Returns to the previous resource if possible.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com/en/registration", "");
if (tab.IsBusy) tab.WaitDownloading();
tab.GoBack();
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com/en/registration", "");
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->GoBack();
return 0;
}GetElementFromPoint
Method
Returns the HTML element located at specified coordinates.
Parameters
| Параметр | Описание |
|---|---|
x | The coordinate of x. |
y | The coordinate of y. |
Returns: The element located at specified coordinates.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// get element from point
HtmlElement he = tab.GetElementFromPoint(50, 50);
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// get element from point
$he = $tab->GetElementFromPoint(50, 50);
return 0;
}GetDocumentByAddress
Method
Searches for a document by the address.
Parameters
| Параметр | Описание |
|---|---|
docAddress | The address of a document in the tab. |
Returns: The document corresponds to the specified address.
FindElementByAttribute
Method
Searches for an HTML element 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
| Параметр | Описание |
|---|---|
tags | Tags for search the element. If the count of tags is more than one then they are through ”;“. |
attrName | The attribute name. |
attrValue | The attribute value. |
searchKind | This parameter can take the following values: “text”, “notext” and “regexp”. |
number | The item number in a collection of matching items. |
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.ActiveTab;
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.FindElementByAttribute("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->ActiveTab;
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->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", 0);
return 0;
}FindElementByAttribute
Method
Searches for an HTML element by the attribute, and returns the first occurrence using extended number selector.
If html element was not found then this method returns the HtmlElement object in which IsVoid or IsNill property is “true”.
Parameters
| Параметр | Описание |
|---|---|
tags | Tags for search the element. If the count of tags is more than one then they are through ”;“. |
attrName | The attribute name. |
attrValue | The attribute value. |
searchKind | This parameter can take the following values: “text”, “notext” and “regexp”. |
number | The document address. This can be a number represented as a string or special expression for selection the desired number. The expression is constructed by the rules of the range of values. For example: random1(1,12-15,35-end). |
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.ActiveTab;
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.FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", "random");
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
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->FindElementByAttribute("input:checkbox", "fulltag", "input:checkbox", "text", "random");
return 0;
}FindElementsByAttribute
Method
Searches for all HTML elements by the attribute.
Parameters
| Параметр | Описание |
|---|---|
tags | Tags for search the elements. If the number of tags is more than one then they are through ”;“. |
attrName | The attribute name. |
attrValue | The attribute value. |
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.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// find elements by attribute
HtmlElementCollection heCol = tab.FindElementsByAttribute("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->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// find elements by attribute
$heCol = $tab->FindElementsByAttribute("input:checkbox", "fulltag", "input:checkbox", "text");
return 0;
}FindElementById
Method
Searches for an HTML element 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
| Параметр | Описание |
|---|---|
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.ActiveTab;
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");
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
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");
return 0;
}FindElementsById
Method
Searches for all HTML elements by the ID.
Parameters
| Параметр | Описание |
|---|---|
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.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// find elements by id
HtmlElementCollection heCol = tab.FindElementsById("overview");
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// find elements by id
$heCol = $tab->FindElementsById("overview");
return 0;
}FindElementByName
Method
Searches for an HTML element 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
| Параметр | Описание |
|---|---|
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.ActiveTab;
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 = tab.FindElementByName("text");
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab.->sNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// find element by name
$he = $tab->FindElementByName("text");
return 0;
}FindElementsByName
Method
Searches for all HTML elements by the name.
Parameters
| Параметр | Описание |
|---|---|
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.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// find elements by name
HtmlElementCollection heCol = tab.FindElementsByName("text");
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// find elements by name
$heCol = $tab->FindElementsByName("text");
return 0;
}FindElementByTag
Method
Searches for an HTML element 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
| Параметр | Описание |
|---|---|
tag | Tag for search the element. |
number | The item number in a collection of matching items. |
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.ActiveTab;
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 tag
HtmlElement he = tab.FindElementByTag("input:radio", 0);
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
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 tag
$he = $tab->FindElementByTag("input:radio", 0);
return 0;
}FindElementsByTags
Method
Searches for all HTML elements by the tags.
Parameters
| Параметр | Описание |
|---|---|
tags | Tags for search the elements. If the number 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.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// find elements by tag
HtmlElementCollection heCol1 = tab.FindElementsByTags("input:checkbox");
// find elements by tags
HtmlElementCollection heCol2 = tab.FindElementsByTags("input:checkbox;input:radio");
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// find elements by tag
$heCol1 = $tab->FindElementsByTags("input:checkbox");
// find elements by tags
$heCol2 = $tab->FindElementsByTags("input:checkbox;input:radio");
return 0;
}FindElementByXPath
Method
Searches for an HTML element by the xpath, 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
| Параметр | Описание |
|---|---|
xpath | XPath for search the element. |
number | The item number in a collection of matching items. |
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.ActiveTab;
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 xpath
HtmlElement he = tab.FindElementByXPath("/html/body/div/div[@class]", 0);
if (he.IsVoid) return -2;
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
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 xpath
$he = $tab->FindElementByXPath("/html/body/div/div[@class]", 0);
if ($he->IsVoid) return -2;
return 0;
}FindElementsByXPath
Method
Searches for all HTML elements by the xpath.
Parameters
| Параметр | Описание |
|---|---|
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.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// find elements by xpath
HtmlElementCollection heCol1 = tab.FindElementsByXPath("/html/body/div/div[@class]");
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// find elements by xpath
$heCol1 = $tab->FindElementsByXPath("/html/body/div/div[@class]");
return 0;
}QuerySelector
Method
Searches for an HTML element by the css selector, 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
| Параметр | Описание |
|---|---|
selector | Css selector for search the element. |
number | The item number in a collection of matching items. Default value is 0. |
Returns: The first element that matches the conditions defined by the name, if found; otherwise, the result is void.
Example
// 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 html element by css selector
var he = tab.QuerySelector(".inputs", 1);
if (he.IsVoid) return -2;
he.Click();QuerySelectorAll
Method
Searches for all HTML elements by the css selector.
Parameters
| Параметр | Описание |
|---|---|
selector | Css selector 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
// clear cookies
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 elements by css selector
var collection = tab.QuerySelectorAll(".inputs");
return collection.Count;GetSourceText
Method
Returns the text of the page that the user sees.
Parameters
| Параметр | Описание |
|---|---|
encoding | The encoding type. |
Returns: The text of a page that the user sees.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// get source text
string text = tab.GetSourceText("utf-8");
// go to lessons.zennolab.com
tab.Navigate("lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// set source text
tab.SetSourceText(text);
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// get source text
$text = $tab->GetSourceText("utf-8");
// go to lessons.zennolab.com
$tab->Navigate("lessons.zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// set source text
$tab->SetSourceText($text);
return 0;
}SetSourceText
Method
Sets the text of the page that the user sees.
Parameters
| Параметр | Описание |
|---|---|
value | The new text of the page. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// get source text
string text = tab.GetSourceText("utf-8");
// go to lessons.zennolab.com
tab.Navigate("lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// set source text
tab.SetSourceText(text);
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// get source text
$text = $tab->GetSourceText("utf-8");
// go to lessons.zennolab.com
$tab->Navigate("lessons.zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// set source text
$tab->SetSourceText($text);
return 0;
}GetCharset
Method
Gets the charset of the tab.
Returns: The name of charset of the tab.
SetCharset
Method
Sets the charset to the tab.
Parameters
| Параметр | Описание |
|---|---|
value | Name of the charset. Empty string sets charset to default. |
Close
Method
Closes the tab.
The Close method closes the tab if it is not only one. In the instance window always exists at least one tab.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to lessons.zennolab.com
Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// go to zennolab.com
tab = instance.NewTab("New");
tab.Navigate("zennolab.com", "");
if (tab.IsBusy) tab.WaitDownloading();
// close the tab
tab.Close();
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// go to zennolab.com
$tab = $instance->NewTab("New");
$tab->Navigate("zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
// close the tab
$tab->Close();
return 0;
}GetNull
Method
Возвращает пустой таб
GetHtmlElement
Method
Searches the html element by specified parameters.
Parameters
| Параметр | Описание |
|---|---|
doc | The document address. |
form | The form number. |
tag | The tag of the html element. |
parameters | The search parameters. |
Returns: The first element that matches the conditions defined by the parameters, if found; otherwise, the result is void.
FindImage
Method
Searches the specified image in specified rectangle area.
The use of the method requires a fairly large amount of computer resources. Not recommended to use it to search for a larger image.
Parameters
| Параметр | Описание |
|---|---|
imageHash | The hash of the image. The image represented as a string. |
rectangles | The rectangular area of search. |
confidenceInterval | The exact matches. This parameter defines percent of similarities for search of the necessary parts. It should be in range from 95 to 99 including border. |
Returns: The rectangular area in the coordinates of the page. The string has the follow format: “Left, Top, Width, Height”.
RiseEvent
Method
Rise specified event in the rectangular area.
Parameters
| Параметр | Описание |
|---|---|
eventName | The event name. |
rectangle | The rectangular area. |
clickType | The mouse button type. It’s can have a value “Left”, “Right”, “DoubleClick”. |
Example
// clear cookie
instance.ClearCookie();
// navigate to lessons.zennolab.com
instance.ActiveTab.Navigate("lessons.zennolab.com", String.Empty);
// wait downloading
if (instance.ActiveTab.IsBusy) instance.ActiveTab.WaitDownloading();
// create rectangular area
Rectangle rec = new Rectangle(600, 95, 120, 25);
// rise event
instance.ActiveTab.RiseEvent("click", rec, "Left");
// wait downloading
instance.ActiveTab.WaitDownloading();Example2
// clear cookie
$instance->ClearCookie();
// navigate to lessons.zennolab.com
$instance->ActiveTab->Navigate("lessons.zennolab.com", "");
// wait downloading
if ($instance->ActiveTab->IsBusy) $instance->ActiveTab->WaitDownloading();
// create rectangular area
$rec = new Rectangle(600, 95, 120, 25);
// rise event
$instance->ActiveTab->RiseEvent("click", rec, "Left");
// wait downloading
$instance->ActiveTab->WaitDownloading();DragDrop
Method
Performs the drag and drop events inside tab.
Parameters
| Параметр | Описание |
|---|---|
fromX | The x coordinate inside tab’s area for rise drag event. |
fromY | The y coordinate inside tab’s area for rise drag event. |
toX | The x coordinate inside tab’s area for rise drop event. |
toY | The y coordinate inside tab’s area for rise drop event. |
Example
// rise drag and drop events in specific positions
instance.ActiveTab.DragDrop(100, 100, 200, 200);Example2
// rise drag and drop events in specific positions
$instance->ActiveTab->DragDrop(100, 100, 200, 200);MouseMove
Method
Performs the mouse move event from point to point in specified coordinates inside the current tab.
Parameters
| Параметр | Описание |
|---|---|
fromX | The x coordinate of the start point inside tab’s area for rise mouse move event. |
fromY | The y coordinate of the start point inside tab’s area for rise mouse move event. |
toX | The x coordinate of the end point inside tab’s area for rise mouse move event. |
toY | The y coordinate of the end point inside tab’s area for rise mouse move event. |
useClick | true if necessary performs the left mouse click in the end point: otherwise false. Default value is false. |
considerScroll | true if necessary to consider scroll position of the browser; otherwise false. Default value is false. |
Example
// performs the mouse moving from [200, 250] to [500, 250]
instance.ActiveTab.MouseMove(200, 250, 500, 250, false, false);
// and next
// preforms the mouse moving from [500, 250] to [500, 125]
// and rise left mouse click in the last location
instance.ActiveTab.MouseMove(500, 250, 500, 125, true, false);Example2
// performs the mouse moving from [200, 250] to [500, 250]
$instance->ActiveTab->MouseMove(200, 250, 500, 250, false, false);
// and next
// preforms the mouse moving from [500, 250] to [500, 125]
// and rise left mouse click in the last location
$instance->ActiveTab->MouseMove(500, 250, 500, 125, true, false);MouseMove
Method
Performs the mouse move event in specified point inside the current tab.
Parameters
| Параметр | Описание |
|---|---|
toX | The x coordinate inside tab’s area for rise mouse move event. |
toY | The y coordinate inside tab’s area for rise mouse move event. |
useClick | true if necessary performs the left mouse click in the end point: otherwise false. Default value is false. |
considerScroll | true if necessary to consider scroll position of the browser; otherwise false. Default value is false. |
Example
// performs the mouse moving to [500, 250]
instance.ActiveTab.MouseMove(500, 250, false, false);
// and next
// preforms the mouse moving to [500, 125]
// and rise left mouse click in this location
instance.ActiveTab.MouseMove(500, 125, true, false);Example2
// performs the mouse moving to [500, 250]
$instance->ActiveTab->MouseMove(500, 250, false, false);
// and next
// preforms the mouse moving to [500, 125]
// and rise left mouse click in this location
$instance->ActiveTab->MouseMove(500, 125, true, false);MouseMove
Method
Performs the mouse move event in specified array of the coordinates with delay between all moving.
The parameter delay can be null or empty. In this case the method uses the default value of the delay. Also the length of delay and points can be different.
Parameters
| Параметр | Описание |
|---|---|
useClick | true if necessary performs the left mouse click in the end point: otherwise false. Default value is false. |
points | An array of the points where are performed the mouse move event. |
delay | An array of the delay in milliseconds for each position. |
considerScroll | true if necessary to consider scroll position of the browser; otherwise false. Default value is false. |
Example
// create points
Point[] points = new Point[10]
{
new Point(100, 100),
new Point(110, 110),
new Point(120, 120),
new Point(130, 130),
new Point(140, 140),
new Point(150, 150),
new Point(160, 160),
new Point(170, 170),
new Point(180, 180),
new Point(190, 190)
};
// create delay
int[] delay = new int[10] { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 };
// perform the mouve move events
instance.ActiveTab.MouseMove(points, delay, false, false);Example2
// create points
$points = array(
new System\Drawing\Point(100, 100),
new System\Drawing\Point(110, 110),
new System\Drawing\Point(120, 120),
new System\Drawing\Point(130, 130),
new System\Drawing\Point(140, 140),
new System\Drawing\Point(150, 150),
new System\Drawing\Point(160, 160),
new System\Drawing\Point(170, 170),
new System\Drawing\Point(180, 180),
new System\Drawing\Point(190, 190)
);
// create delay
$delay = array(100, 100, 100, 100, 100, 100, 100, 100, 100, 100);
// perform the mouve move events
$instance->ActiveTab->MouseMove($points, $delay, false, false);MouseClick
Method
Performs the mouse click event in specified point inside the current tab.
Parameters
| Параметр | Описание |
|---|---|
x | The x coordinate inside tab’s area for rise mouse click event. |
y | The y coordinate inside tab’s area for rise mouse click event. |
button | The mouse button. It can be “left”, “right” or “middle”. |
mouseEvent | The mouse button event. It can be “click”, “down” or “up”. |
considerScroll | true if necessary to consider scroll position of the browser; otherwise false. Default value is false. |
Example
// perform left mouse click in location [100,200]
instance.ActiveTab.MouseClick(100, 200, "left", "click");
// perform right mouse down in location [100,200]
instance.ActiveTab.MouseClick(150, 300, "right", "down");Example2
// perform left mouse click in location [100,200]
$instance->ActiveTab->MouseClick(100, 200, "left", "click");
// perform right mouse down in location [100,200]
$instance->ActiveTab->MouseClick(150, 300, "right", "down");MouseWheel
Method
Performs the mouse wheel event in specified point inside the current tab.
Parameters
| Параметр | Описание |
|---|---|
x | The x coordinate inside tab’s area for rise mouse wheel event. |
y | The y coordinate inside tab’s area for rise mouse wheel event. |
deltaX | The size of step in pixel along the x axis. |
deltaY | The size of step in pixel along the y axis. |
considerScroll | true if necessary to consider scroll position of the browser; otherwise false. Default value is false. |
Example
// perform mouse wheel
instance.ActiveTab.MouseWheel(100, 200, 0, 100, false);Example2
// perform mouse wheel
$instance->ActiveTab->MouseWheel(100, 200, 0, 100, false);FullEmulationMouseGetCopyOfOptions
Method
Returns a copy of MouseEmulationParameters that are being used in the current tab of browser instance. Mind that this is only a copy, and changes to it will not affect anything unless you call SetTouchEmulationParameters
Returns: A copy of MouseEmulationParameters that are being used in the current tab of browser instance.
FullEmulationMouseSetOptions
Method
Sets touch emulation parameters of the current browser instance to the value passed in it.
Parameters
| Параметр | Описание |
|---|---|
value | TouchEmulationParameters that are to be used in the current browser instance. |
FullEmulationMouseSetOptions
Method
Configure full mouse emulation. These parameters set to default value every navigate.
Parameters
| Параметр | Описание |
|---|---|
pause | Pause in milliseconds between every mouse point generation. |
pauseVariance | Pause variance (pause +- pauseVariance). |
pointDistanse | The pitch in a straight line between points. |
rectangleBasePointPartWidth | Part of the rectangle for start point by the width |
rectangleBasePointPartHeight | Part of the rectangle for start point by the height |
rectangleEndPointPartWidth | Part of the rectangle for end point by the width |
Example
instance.ActiveTab.FullEmulationMouseSetOptions(50);
instance.ActiveTab.FullEmulationMouseMove(50,500);Example2
$instance->ActiveTab->FullEmulationMouseSetOptions(50, 5, 5);
$instance->ActiveTab->FullEmulationMouseMove(500, 500);FullEmulationMouseSetScrollBorder
Method
Configure border for scrolling. These parameters set to default value every navigate.
Parameters
| Параметр | Описание |
|---|---|
scrollX | X scroll border size. |
scrollY | Y scroll border size. |
Example
instance.ActiveTab.FullEmulationMouseSetScrollBorder(0, 0);
instance.ActiveTab.FullEmulationMouseMove(50,500);Example2
$instance->ActiveTab->FullEmulationMouseSetScrollBorder(0, 0);
$instance->ActiveTab->FullEmulationMouseMove(500, 500);FullEmulationMouseMove
Method
Performs the mouse move event to specified coordinates.
Parameters
| Параметр | Описание |
|---|---|
toX | The x coordinate inside tab’s area for move mouse. |
toY | The y coordinate inside tab’s area for move mouse. |
Example
instance.ActiveTab.FullEmulationMouseMove(500,500);
instance.ActiveTab.FullEmulationMouseMove(50,500);
instance.ActiveTab.FullEmulationMouseMove(250,200);Example2
$instance->ActiveTab->FullEmulationMouseMove(500, 500);FullEmulationMouseMoveToHtmlElement
Method
Performs the mouse move event to specified element.
Parameters
| Параметр | Описание |
|---|---|
he | The HTMLElement for move mouse. |
Example
HtmlElement he = instance.ActiveTab.GetDocumentByAddress("0").FindElementByAttribute("div", "class", "main", "regexp", 0);
if (he.IsVoid) return -1;
instance.ActiveTab.FullEmulationMouseMoveToHtmlElement(he);Example2
$he = $instance->ActiveTab->GetDocumentByAddress("0")->FindElementByAttribute("div", "class", "main", "regexp", 0);
if (!he->IsVoid)
$instance->ActiveTab->FullEmulationMouseMoveToHtmlElement(he);FullEmulationMouseMoveAboveHtmlElement
Method
Performs the mouse move event above specified element.
Parameters
| Параметр | Описание |
|---|---|
he | The HTMLElement for move mouse. |
sizeOfType | The size of type. |
Example
HtmlElement he = instance.ActiveTab.GetDocumentByAddress("0").FindElementByAttribute("div", "class", "main", "regexp", 0);
if (he.IsVoid) return -1;
instance.ActiveTab.FullEmulationMouseMoveAboveHtmlElement(he, 40);Example2
$he = $instance->ActiveTab->GetDocumentByAddress("0")->FindElementByAttribute("div", "class", "main", "regexp", 0);
if (!he->IsVoid)
$instance->ActiveTab->FullEmulationMouseMoveAboveHtmlElement(he, 40);FullEmulationMouseWheel
Method
Performs the mouse wheel event.
Parameters
| Параметр | Описание |
|---|---|
deltaX | The size of step in pixel along the x axis. |
deltaY | The size of step in pixel along the y axis. |
Example
instance.ActiveTab.FullEmulationMouseWheel(0,100);Example2
$instance->ActiveTab->FullEmulationMouseWheel(0, 100);FullEmulationMouseWheel
Method
Scroll page to specified element. If element
Parameters
| Параметр | Описание |
|---|---|
he | Target HTML element |
topOffsetToElementCenter | Target he`s middle point offset from top viewport border, % of viewport height |
leftOffsetToElementCenter | Target he`s middle point offset from left viewport border, % of viewport width /// |
Example
HtmlElement he = instance.ActiveTab.QuerySelector("#target");
instance.ActiveTab.FullEmulationMouseWheel(he,30);Example2
$he = instance->ActiveTab->QuerySelector("#target");
$instance->ActiveTab->FullEmulationMouseWheel($he, 30);FullEmulationMouseClick
Method
Performs the mouse click event in current point inside the current tab.
Parameters
| Параметр | Описание |
|---|---|
button | The mouse button. It can be “left”, “right” or “middle”. |
mouseEvent | The mouse button event. It can be “click”, “down” or “up”. |
Example
instance.ActiveTab.FullEmulationMouseMove(500,500);
instance.ActiveTab.FullEmulationMouseClick("left", "click");Example2
$instance->ActiveTab->FullEmulationMouseMove(500,500);
$instance->ActiveTab->MouseClick("left", "click");FullEmulationMouseDragAndDrop
Method
Performs the mouse drag and drop event from specified coordinates to specified coordinates.
Parameters
| Параметр | Описание |
|---|---|
fromX | The x coordinate inside tab’s area for start drag. |
fromY | The y coordinate inside tab’s area for start drag. |
toX | The x coordinate inside tab’s area for drop. |
toY | The y coordinate inside tab’s area for drop. |
Example
instance.ActiveTab.FullEmulationMouseDragAndDrop(100,100, 500, 500);Example2
$instance->ActiveTab->FullEmulationMouseDragAndDrop(100,100, 500, 500);FullEmulationMouseDragAndDrop
Method
Performs the mouse drag and drop from specified element to specified element.
Parameters
| Параметр | Описание |
|---|---|
fromHe | The HTMLElement for start drag. |
toHe | The HTMLElement for drop. |
Example
HtmlElement fromHe = instance.ActiveTab.GetDocumentByAddress("0").FindElementByAttribute("div", "class", "main", "regexp", 0);
if (fromHe.IsVoid) return -1;
HtmlElement toHe = instance.ActiveTab.GetDocumentByAddress("0").FindElementByAttribute("div", "class", "main", "regexp", 1);
if (to.IsVoid) return -1;
instance.ActiveTab.FullEmulationMouseDragAndDrop(fromHe, toHe);Example2
$fromHe = $instance->ActiveTab->GetDocumentByAddress("0")->FindElementByAttribute("div", "class", "main", "regexp", 0);
if (fromHe->IsVoid) return;
$toHe = $instance->ActiveTab->GetDocumentByAddress("0")->FindElementByAttribute("div", "class", "main", "regexp", 1);
if ($toHe->IsVoid) return;
$instance->ActiveTab->FullEmulationMouseDragAndDrop(fromHe, toHe);KeyEvent
Method
Performs the key event inside the current tab.
Parameters
| Параметр | Описание |
|---|---|
key | The key for event. For addtional characters you can use enumeration members from https://msdn.microsoft.com/en-us/library/system.windows.input.key.aspx |
keyEvent | The type of key event. It can be “down”, “press” or “up”. |
keyModifer | The key modifier for key event. It can be “alt”, “ctrl”, “shift”, or empty string (not use the key modifier). |
Example
// performs the press key event with modifier
instance.ActiveTab.KeyEvent("V", "press", "ctrl");
instance.ActiveTab.KeyEvent("Tab", "press", "alt");
instance.ActiveTab.KeyEvent("S", "press", "shift");
instance.ActiveTab.KeyEvent("V", "down", ""); // push
instance.ActiveTab.KeyEvent("V", "up", ""); // releaseExample2
// performs the press key event with modifier
$instance->ActiveTab->KeyEvent("A", "press", "ctrl");SetActive
Method
Sets the current tab as active.
Example
// set tab as active
instance.ActiveTab.SetActive();Example2
// set tab as active
$instance->ActiveTab->SetActive();GetPagePreview
Method
Gets preview of page.
The preview size does not exceed 2000 * 2000 pixels.
Returns: The image as a string value.
Example
// get page preview
var preview = instance.ActiveTab.GetPagePreview();
var ms = new System.IO.MemoryStream(Convert.FromBase64String(preview));
var bmp = new Bitmap(ms);
ms.Close();
// save to image
bmp.Save("example.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);Example2
// get page preview
$preview = $instance->ActiveTab->GetPagePreview();
$ms = new System\IO\MemoryStream(System\Convert::FromBase64String($preview));
$bmp = new System\Drawing\Bitmap($ms);
$ms->Close();
// save to image
$bmp->Save("example.jpg", System\Drawing\Imaging\ImageFormat::Jpeg);DropFile
Method
Drop file to the page.
Parameters
| Параметр | Описание |
|---|---|
filepath | The path to file. |
x | The x coordinate of the drop point inside tab’s area for rise dragdrop move event. |
y | The y coordinate of the drop point inside tab’s area for rise dragdrop move event. |
SubscribePageLoading
Method
Subscribe javascript code to DOMContentLoaded event on page.
Parameters
| Параметр | Описание |
|---|---|
script | The javascipt code. |
loadType | Type of code usage (onetime, domain, alltime). |
domain | The domain for subscribe if choosen loadType is “domain”. Optioal field. |
useAllTabs | true if needs evaluate script in all tabs, works only for “domain” and “alltime” types; otherwise false. Default value is false. |
SubscribeWindowCreating
Method
Subscribe javascript code to DOMWindowCreated event on page.
Parameters
| Параметр | Описание |
|---|---|
script | The javascipt code. |
loadType | Type of code usage (onetime, domain, alltime). |
domain | The domain for subscribe if choosen loadType is “domain”. Optioal field. |
useAllTabs | true if needs evaluate script in all tabs, works only for “domain” and “alltime” types; otherwise false. Default value is false. |
GetTraffic
Method
Returns collection of requests for current tab.
Parameters
| Параметр | Описание |
|---|---|
urlFilters | Collection of regexs to filter traffic by url contents. If traffic item match any of regexs, it will put to result. |
headerFilters | Collection of regexs to filter traffic by request or response header contents. If traffic item match any of regexs, it will put to result. |
bodyFilters | Collection of regexs to filter traffic by request or response body contents. If traffic item match any of regexs, it will put to result. |
Returns: Collection of requests.
Example
instance.SetContentPolicy("BlockList", new []{ "mc.yandex.ru" }, null);
instance.UseTrafficMonitoring = false;
Tab tab = instance.ActiveTab;
// navigate to url
instance.ClearCache();
instance.ClearCookie();
tab.Navigate("http://lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get list of requests
var traffic = instance.ActiveTab.GetTraffic();
// print count of items, it will be more than 0
project.SendInfoToLog("First count of traffic elements = " + traffic.Count());
// get some data from items and log it
foreach(var t in traffic)
project.SendInfoToLog(string.Format("Url: {0}\r\n Method: {1}\r\n Result: {2}", t.Url, t.Method, t.ResultCode));
// get list of request second time
traffic = instance.ActiveTab.GetTraffic();
// print count of items, it will be 0, because the previous method call removed the old items
project.SendInfoToLog("Second count of traffic elements = " + traffic.Count());
// navigate to url
instance.ClearCache();
instance.ClearCookie();
tab.Navigate("http://lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get reqest by urls filter collection
traffic = instance.ActiveTab.GetTraffic(new [] {"http://lessons.zennolab.com/main.css"});
project.SendInfoToLog("Request by urls filter:");
foreach(var t in traffic)
project.SendInfoToLog("Url: " + t.Url);
// result collection must has one item
if (traffic.Count(t => !t.IsBlocked) != 1)
throw new Exception("Traffic collection count != 1");
// this item must match the filter collection
if (traffic.First().Url != "http://lessons.zennolab.com/main.css")
throw new Exception("Traffic item url != http://lessons.zennolab.com/main.css");
// RequestHeaders and other additional fields must be null while instance.UseTrafficMonitoring == false
if (!string.IsNullOrWhiteSpace(traffic.First().RequestHeaders))
throw new Exception("Instance.UseTrafficMonitoring (false) is not working, value = " + instance.UseTrafficMonitoring);
// get list of request second time, second result list must be empty
traffic = instance.ActiveTab.GetTraffic().ToList();
if (traffic.Count(t => !t.IsBlocked) != 0)
throw new Exception("Second traffic collection count != 0");
// enable additional traffic monitoring
instance.UseTrafficMonitoring = true;
// navigate to url
instance.ClearCache();
instance.ClearCookie();
tab.Navigate("http://lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get list of requests by urls filter collection and headers filter collection
traffic = instance.ActiveTab.GetTraffic(new [] {"http://lessons.zennolab.com/main.css"}, new [] { "image/png" });
project.SendInfoToLog("Request by urls filter collection and headers filter collection:");
foreach(var t in traffic)
project.SendInfoToLog("Url: " + t.Url);
// result collection must has two item, first match url regex, second match header regex
if (traffic.Count(t => !t.IsBlocked) != 2)
throw new Exception("Traffic collection count != 2");
// all items must contains RequestHeaders and other fields, because instance.UseTrafficMonitoring == true
if (traffic.Any(t => string.IsNullOrWhiteSpace(t.RequestHeaders)))
throw new Exception("Instance.UseTrafficMonitoring (true) is not working, value = " + instance.UseTrafficMonitoring);
// get list of request second time, second result list must be empty
traffic = instance.ActiveTab.GetTraffic().ToList();
if (traffic.Count(t => !t.IsBlocked) != 0)
throw new Exception("Second traffic collection count != 0");
// navigate to url
instance.ClearCache();
instance.ClearCookie();
tab.Navigate("http://lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get list of requests by urls, headers and body filter collection
traffic = instance.ActiveTab.GetTraffic(new [] {"http://lessons.zennolab.com/main.css"}, new [] { "image/png" }, new [] { "DOCTYPE HTML PUBLIC" });
project.SendInfoToLog("Request by urls filter collection and headers filter collection:");
foreach(var t in traffic)
project.SendInfoToLog("Url: " + t.Url);
// result collection must has three item
if (traffic.Count(t => !t.IsBlocked) != 3)
throw new Exception("Traffic collection count != 3");
// all items must contains RequestHeaders and other fields, because instance.UseTrafficMonitoring == true
if (traffic.Any(t => string.IsNullOrWhiteSpace(t.RequestHeaders)))
throw new Exception("Instance.UseTrafficMonitoring (true) is not working, value = " + instance.UseTrafficMonitoring);
// get list of request second time, second result list must be empty
traffic = instance.ActiveTab.GetTraffic().ToList();
if (traffic.Count(t => !t.IsBlocked) != 0)
throw new Exception("Second traffic collection count != 0");GetTraffic
Method
Returns collection of requests for current tab, accepting extended parameters..
Parameters
| Параметр | Описание |
|---|---|
settings | Object with various settings for GetTraffic. |
Returns: Collection of requests.
Example
instance.SetContentPolicy("BlockList", new[] { "mc.yandex.ru" }, null);
instance.UseTrafficMonitoring = true;
Tab tab = instance.ActiveTab;
// navigate to url
instance.ClearCache();
instance.ClearCookie();
tab.Navigate("https://lessons.zennolab.com");
if (tab.IsBusy)
tab.WaitDownloading();
ZennoLab.CommandCenter.Classes.GetTrafficSettings getTrafficSettings = new ZennoLab.CommandCenter.Classes.GetTrafficSettings();
getTrafficSettings.UrlFilters = new[] { "https://lessons.zennolab.com/main.css" };
getTrafficSettings.HeaderFilters = new[] { "image/png" };
getTrafficSettings.BodyFilters = new[] { "DOCTYPE HTML PUBLIC" };
getTrafficSettings.GatherAllTraffic = true;
// get list of requests by urls, headers and body filter collection
var traffic = instance.ActiveTab.GetTraffic(getTrafficSettings);
project.SendInfoToLog("Request by urls filter collection and headers filter collection:");
foreach (var t in traffic)
project.SendInfoToLog("Url: " + t.Url);
// result collection must has three item
if (traffic.Count(t => !t.IsBlocked) != 3)
throw new Exception("Traffic collection count != 3");
// all items must contains RequestHeaders and other fields, because instance.UseTrafficMonitoring == true
if (traffic.Any(t => string.IsNullOrWhiteSpace(t.RequestHeaders)))
throw new Exception("Instance.UseTrafficMonitoring (true) is not working, value = " + instance.UseTrafficMonitoring);
// get list of request second time, second call must not be empty
traffic = instance.ActiveTab.GetTraffic(getTrafficSettings);
if (traffic.Count() == 0)
throw new Exception("Second traffic collection count == 0");
// set GatherAllTraffic is false
getTrafficSettings.GatherAllTraffic = false;
traffic = instance.ActiveTab.GetTraffic(getTrafficSettings);
// get list of request third time, third call must be empty, because GatherAllTraffic = false
if (traffic.Count() != 0)
throw new Exception("Third traffic collection count != 0");