Tab

Assembly: ZennoLab.CommandCenter
Full name: ZennoLab.CommandCenter.Tab
Kind: class


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

string Name { get; }

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

bool IsVoid { get; }

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

bool ErrorDetected { get; }

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

int ZP_ID { get; }

Gets the ID which represents tab on the server.

It is used only for the technical purposes

AllDocuments

Property

DocumentCollection AllDocuments { get; }

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

Document MainDocument { get; }

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

HtmlElement MainBody { get; }

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

string URL { get; }

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

string Domain { get; }

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

string MainDomain { get; }

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

string LastAlertTitle { get; }

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

string LastAlertText { get; }

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

string Title { get; }

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

int Handle { get; }

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

bool IsBusy { get; }

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

bool IsInteractive { get; }

Gets the specified tab is interactive.

IsPreComplete

Property

bool IsPreComplete { get; }

Gets the specified tab is pre-complete.

IsNull

Property

bool IsNull { get; }

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;
            }

Property

int NavigateTimeout { get; set; }

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

string DomText { get; }

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

string PageText { get; }

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

string MainPageArticle { get; }

Gets the text of the main page article.

FullEmulationMouseCurrentPosition

Property

Point FullEmulationMouseCurrentPosition { get; set; }

Gets or sets the current full emulation mouse coordinates.

Example

return instance.ActiveTab.FullEmulationMouseCurrentPosition;

Example2

return instance->ActiveTab->FullEmulationMouseCurrentPosition;

FullEmulationMouseTabPosition

Property

Point FullEmulationMouseTabPosition { get; set; }

Gets or sets the current full emulation mouse coordinates in the window.

Example

return instance.ActiveTab.FullEmulationMouseTabPosition;

Example2

return instance->ActiveTab->FullEmulationMouseTabPosition;

Property

bool NavigateErrorDetected { get; }

Gets information about the error detected in the performance last navigation.

PageScale

Property

double PageScale { get; set; }

Gets or sets a value in percent that indicates scale of page.

Touch

Property

TouchSimulation Touch { get; }

Contains methods simulating work with touch screen

Methods

WaitDownloading

Method

void WaitDownloading()

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

void WaitInteractive()

Waits until the status changed to interactive.

WaitPreComplete

Method

void WaitPreComplete()

Waits until the status changed to PreComplite.

Stop

Method

void Stop()

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;
            }

Method

void Navigate(string url, string referrer)

Navigates to a resource identified by a URL with specified referrer.

Parameters

TypeNameDescription
stringurlA string expression that evaluates to the URL.
stringreferrerA 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

void GoBack()

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

HtmlElement GetElementFromPoint(int x, int y)

Returns the HTML element located at specified coordinates.

Parameters

TypeNameDescription
intxThe coordinate of x.
intyThe 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

Document GetDocumentByAddress(string docAddress)

Searches for a document by the address.

Parameters

TypeNameDescription
stringdocAddressThe address of a document in the tab.

Returns: The document corresponds to the specified address.

FindElementByAttribute

Method

HtmlElement FindElementByAttribute(string tags, string attrName, string attrValue, string searchKind, int number)

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

TypeNameDescription
stringtagsTags for search the element. If the count of tags is more than one then they are through ”;“.
stringattrNameThe attribute name.
stringattrValueThe attribute value.
stringsearchKindThis parameter can take the following values​​: “text”, “notext” and “regexp”.
intnumberThe 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

HtmlElement FindElementByAttribute(string tags, string attrName, string attrValue, string searchKind, string number)

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

TypeNameDescription
stringtagsTags for search the element. If the count of tags is more than one then they are through ”;“.
stringattrNameThe attribute name.
stringattrValueThe attribute value.
stringsearchKindThis parameter can take the following values​​: “text”, “notext” and “regexp”.
stringnumberThe 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

HtmlElementCollection FindElementsByAttribute(string tags, string attrName, string attrValue, string searchKind)

Searches for all HTML elements by the attribute.

Parameters

TypeNameDescription
stringtagsTags for search the elements. If the number of tags is more than one then they are through ”;“.
stringattrNameThe attribute name.
stringattrValueThe attribute value.
stringsearchKindThis 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

HtmlElement FindElementById(string id)

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

TypeNameDescription
stringidThe 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

HtmlElementCollection FindElementsById(string id)

Searches for all HTML elements by the ID.

Parameters

TypeNameDescription
stringidThe 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

HtmlElement FindElementByName(string name)

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

TypeNameDescription
stringnameThe 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

HtmlElementCollection FindElementsByName(string name)

Searches for all HTML elements by the name.

Parameters

TypeNameDescription
stringnameThe 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

HtmlElement FindElementByTag(string tag, int number)

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

TypeNameDescription
stringtagTag for search the element.
intnumberThe 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

HtmlElementCollection FindElementsByTags(string tags)

Searches for all HTML elements by the tags.

Parameters

TypeNameDescription
stringtagsTags 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

HtmlElement FindElementByXPath(string xpath, int number)

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

TypeNameDescription
stringxpathXPath for search the element.
intnumberThe 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

HtmlElementCollection FindElementsByXPath(string xpath)

Searches for all HTML elements by the xpath.

Parameters

TypeNameDescription
stringxpathXPath 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

HtmlElement QuerySelector(string selector, int number)

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

TypeNameDescription
stringselectorCss selector for search the element.
intnumberThe 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

HtmlElementCollection QuerySelectorAll(string selector)

Searches for all HTML elements by the css selector.

Parameters

TypeNameDescription
stringselectorCss 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

string GetSourceText(string encoding)

Returns the text of the page that the user sees.

Parameters

TypeNameDescription
stringencodingThe 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

void SetSourceText(string value)

Sets the text of the page that the user sees.

Parameters

TypeNameDescription
stringvalueThe 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

string GetCharset()

Gets the charset of the tab.

Returns: The name of charset of the tab.

SetCharset

Method

void SetCharset(string value)

Sets the charset to the tab.

Parameters

TypeNameDescription
stringvalueName of the charset. Empty string sets charset to default.

Close

Method

void Close()

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;
            }

GetHtmlElement

Method

HtmlElement GetHtmlElement(string doc, string form, string tag, String[] parameters)

Searches the html element by specified parameters.

Parameters

TypeNameDescription
stringdocThe document address.
stringformThe form number.
stringtagThe tag of the html element.
String[]parametersThe search parameters.

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

FindImage

Method

string FindImage(string imageHash, Rectangle[] rectangles, int confidenceInterval)

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

TypeNameDescription
stringimageHashThe hash of the image. The image represented as a string.
Rectangle[]rectanglesThe rectangular area of search.
intconfidenceIntervalThe 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

void RiseEvent(string eventName, Rectangle rectangle, string clickType)

Rise specified event in the rectangular area.

Parameters

TypeNameDescription
stringeventNameThe event name.
RectanglerectangleThe rectangular area.
stringclickTypeThe 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

void DragDrop(int fromX, int fromY, int toX, int toY)

Performs the drag and drop events inside tab.

Parameters

TypeNameDescription
intfromXThe x coordinate inside tab’s area for rise drag event.
intfromYThe y coordinate inside tab’s area for rise drag event.
inttoXThe x coordinate inside tab’s area for rise drop event.
inttoYThe 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

void MouseMove(int fromX, int fromY, int toX, int toY, bool useClick, bool considerScroll)

Performs the mouse move event from point to point in specified coordinates inside the current tab.

Parameters

TypeNameDescription
intfromXThe x coordinate of the start point inside tab’s area for rise mouse move event.
intfromYThe y coordinate of the start point inside tab’s area for rise mouse move event.
inttoXThe x coordinate of the end point inside tab’s area for rise mouse move event.
inttoYThe y coordinate of the end point inside tab’s area for rise mouse move event.
booluseClicktrue if necessary performs the left mouse click in the end point: otherwise false. Default value is false.
boolconsiderScrolltrue 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

void MouseMove(int toX, int toY, bool useClick, bool considerScroll)

Performs the mouse move event in specified point inside the current tab.

Parameters

TypeNameDescription
inttoXThe x coordinate inside tab’s area for rise mouse move event.
inttoYThe y coordinate inside tab’s area for rise mouse move event.
booluseClicktrue if necessary performs the left mouse click in the end point: otherwise false. Default value is false.
boolconsiderScrolltrue 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

void MouseMove(Point[] points, Int32[] delay, bool useClick, bool considerScroll)

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

TypeNameDescription
Point[]pointsAn array of the points where are performed the mouse move event.
Int32[]delayAn array of the delay in milliseconds for each position.
booluseClicktrue if necessary performs the left mouse click in the end point: otherwise false. Default value is false.
boolconsiderScrolltrue 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

void MouseClick(int x, int y, string button, string mouseEvent, bool considerScroll)

Performs the mouse click event in specified point inside the current tab.

Parameters

TypeNameDescription
intxThe x coordinate inside tab’s area for rise mouse click event.
intyThe y coordinate inside tab’s area for rise mouse click event.
stringbuttonThe mouse button. It can be “left”, “right” or “middle”.
stringmouseEventThe mouse button event. It can be “click”, “down” or “up”.
boolconsiderScrolltrue 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

void MouseWheel(int x, int y, double deltaX, double deltaY, bool considerScroll)

Performs the mouse wheel event in specified point inside the current tab.

Parameters

TypeNameDescription
intxThe x coordinate inside tab’s area for rise mouse wheel event.
intyThe y coordinate inside tab’s area for rise mouse wheel event.
doubledeltaXThe size of step in pixel along the x axis.
doubledeltaYThe size of step in pixel along the y axis.
boolconsiderScrolltrue 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

MouseEmulationParameters FullEmulationMouseGetCopyOfOptions()

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

void FullEmulationMouseSetOptions(MouseEmulationParameters value)

Sets touch emulation parameters of the current browser instance to the value passed in it.

Parameters

TypeNameDescription
MouseEmulationParametersvalueTouchEmulationParameters that are to be used in the current browser instance.

FullEmulationMouseSetOptions

Method

void FullEmulationMouseSetOptions(int pause, int pauseVariance, int pointDistanse, float rectangleBasePointPartWidth, float rectangleBasePointPartHeight, float rectangleEndPointPartWidth)

Configure full mouse emulation. These parameters set to default value every navigate.

Parameters

TypeNameDescription
intpausePause in milliseconds between every mouse point generation.
intpauseVariancePause variance (pause +- pauseVariance).
intpointDistanseThe pitch in a straight line between points.
floatrectangleBasePointPartWidthPart of the rectangle for start point by the width
floatrectangleBasePointPartHeightPart of the rectangle for start point by the height
floatrectangleEndPointPartWidthPart 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

void FullEmulationMouseSetScrollBorder(int scrollX, int scrollY)

Configure border for scrolling. These parameters set to default value every navigate.

Parameters

TypeNameDescription
intscrollXX scroll border size.
intscrollYY 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

void FullEmulationMouseMove(int toX, int toY)

Performs the mouse move event to specified coordinates.

Parameters

TypeNameDescription
inttoXThe x coordinate inside tab’s area for move mouse.
inttoYThe 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

void FullEmulationMouseMoveToHtmlElement(HtmlElement he)

Performs the mouse move event to specified element.

Parameters

TypeNameDescription
HtmlElementheThe 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);

FullEmulationMouseMoveToHtmlElement

Method

void FullEmulationMouseMoveToHtmlElement(HtmlElement he, int timeoutMs)

Parameters

TypeNameDescription
HtmlElementhe
inttimeoutMs

FullEmulationMouseMoveAboveHtmlElement

Method

void FullEmulationMouseMoveAboveHtmlElement(HtmlElement he, int sizeOfType)

Performs the mouse move event above specified element.

Parameters

TypeNameDescription
HtmlElementheThe HTMLElement for move mouse.
intsizeOfTypeThe 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

void FullEmulationMouseWheel(int deltaX, int deltaY)

Performs the mouse wheel event.

Parameters

TypeNameDescription
intdeltaXThe size of step in pixel along the x axis.
intdeltaYThe size of step in pixel along the y axis.

Example

instance.ActiveTab.FullEmulationMouseWheel(0,100);

Example2

$instance->ActiveTab->FullEmulationMouseWheel(0, 100);

FullEmulationMouseWheel

Method

void FullEmulationMouseWheel(HtmlElement he, int topOffsetToElementCenter, int leftOffsetToElementCenter)

Scroll page to specified element. If element

Parameters

TypeNameDescription
HtmlElementheTarget HTML element
inttopOffsetToElementCenterTarget he`s middle point offset from top viewport border, % of viewport height
intleftOffsetToElementCenterTarget 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

void FullEmulationMouseClick(string button, string mouseEvent)

Performs the mouse click event in current point inside the current tab.

Parameters

TypeNameDescription
stringbuttonThe mouse button. It can be “left”, “right” or “middle”.
stringmouseEventThe 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

void FullEmulationMouseDragAndDrop(int fromX, int fromY, int toX, int toY)

Performs the mouse drag and drop event from specified coordinates to specified coordinates.

Parameters

TypeNameDescription
intfromXThe x coordinate inside tab’s area for start drag.
intfromYThe y coordinate inside tab’s area for start drag.
inttoXThe x coordinate inside tab’s area for drop.
inttoYThe 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

void FullEmulationMouseDragAndDrop(HtmlElement fromHe, HtmlElement toHe)

Performs the mouse drag and drop from specified element to specified element.

Parameters

TypeNameDescription
HtmlElementfromHeThe HTMLElement for start drag.
HtmlElementtoHeThe 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

void KeyEvent(string key, string keyEvent, string keyModifer)

Performs the key event inside the current tab.

Parameters

TypeNameDescription
stringkeyThe key for event. For addtional characters you can use enumeration members from https://msdn.microsoft.com/en-us/library/system.windows.input.key.aspx
stringkeyEventThe type of key event. It can be “down”, “press” or “up”.
stringkeyModiferThe 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", ""); // release

Example2

// performs the press key event with modifier
            $instance->ActiveTab->KeyEvent("A", "press", "ctrl");

SetActive

Method

void SetActive()

Sets the current tab as active.

Example

// set tab as active
            instance.ActiveTab.SetActive();

Example2

// set tab as active
            $instance->ActiveTab->SetActive();

GetPagePreview

Method

string GetPagePreview()

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

void DropFile(string filepath, int x, int y)

Drop file to the page.

Parameters

TypeNameDescription
stringfilepathThe path to file.
intxThe x coordinate of the drop point inside tab’s area for rise dragdrop move event.
intyThe y coordinate of the drop point inside tab’s area for rise dragdrop move event.

SubscribePageLoading

Method

void SubscribePageLoading(string script, string loadType, string domain, bool useAllTabs)

Subscribe javascript code to DOMContentLoaded event on page.

Parameters

TypeNameDescription
stringscriptThe javascipt code.
stringloadTypeType of code usage (onetime, domain, alltime).
stringdomainThe domain for subscribe if choosen loadType is “domain”. Optioal field.
booluseAllTabstrue if needs evaluate script in all tabs, works only for “domain” and “alltime” types; otherwise false. Default value is false.

SubscribeWindowCreating

Method

void SubscribeWindowCreating(string script, string loadType, string domain, bool useAllTabs)

Subscribe javascript code to DOMWindowCreated event on page.

Parameters

TypeNameDescription
stringscriptThe javascipt code.
stringloadTypeType of code usage (onetime, domain, alltime).
stringdomainThe domain for subscribe if choosen loadType is “domain”. Optioal field.
booluseAllTabstrue if needs evaluate script in all tabs, works only for “domain” and “alltime” types; otherwise false. Default value is false.

GetTraffic

Method

IEnumerable<TrafficItem> GetTraffic(IEnumerable<string> urlFilters, IEnumerable<string> headerFilters, IEnumerable<string> bodyFilters)

Returns collection of requests for current tab.

Parameters

TypeNameDescription
IEnumerable<string>urlFiltersCollection of regexs to filter traffic by url contents. If traffic item match any of regexs, it will put to result.
IEnumerable<string>headerFiltersCollection of regexs to filter traffic by request or response header contents. If traffic item match any of regexs, it will put to result.
IEnumerable<string>bodyFiltersCollection 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

IEnumerable<TrafficItem> GetTraffic(GetTrafficSettings settings)

Returns collection of requests for current tab, accepting extended parameters..

Parameters

TypeNameDescription
GetTrafficSettingssettingsObject 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");