Instance
Assembly: ZennoLab.CommandCenter
Full name: ZennoLab.CommandCenter.Instance
Represents a browser’s window of ZennoPoster
The Instance class contain the properties such as ErrorDetected and IsVoid. Their use necessary for the correct work of your code.
Constructor
Instance()
Method
Initialize a new instance of the Instance class with deafult url and address
Parameters
| Параметр | Описание |
|---|---|
port | The port of the instance. |
Example
// create a new instance
Instance instance = new Instance(40500);Example2
// create a new instance
$instance = new Instance(40500);Instance()
Method
Initialize a new instance of the Instance class
Parameters
| Параметр | Описание |
|---|---|
url | A string expression that evaluates to the URL. |
port | The port of the instance. |
address | This parameter can take the following values: “debug” and “server”. The default value is “server”. |
Example
// create a new instance
Instance instance = new Instance("127.0.0.1", 40500, "server");Example2
// create a new instance
$instance = new Instance("127.0.0.1", 40500, "server");Instance()
Method
Initialize a new instance of the Instance class with deafult url and address
Parameters
| Параметр | Описание |
|---|---|
port | The port of the instance. |
connectionType | The connection type of the instance. |
Example
// create a new instance
Instance instance = new Instance(40500, ConnectionType.Pipe);Example2
// create a new instance
$instance = new Instance(40500, ConnectionType.Pipe);Instance()
Method
Initialize a new instance of the Instance class
Parameters
| Параметр | Описание |
|---|---|
url | A string expression that evaluates to the URL. |
port | The port of the instance. |
address | This parameter can take the following values: “debug” and “server”. The default value is “server”. |
connectionType | The connection type of the instance. |
Example
// create a new instance
Instance instance = new Instance("127.0.0.1", 40500, "server", ConnectionType.Pipe);Example2
// create a new instance
$instance = new Instance("127.0.0.1", 40500, "server", ConnectionType.Pipe);Properties
Transfer
Property
Port
Property
Gets or sets the current port of the Instance object.
Url
Property
Gets the host of the pipe.
Address
Property
Get instances mode.
IsVoid
Property
Gets the specified instance 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;
}ZP_ID
Property
Gets the ID which represents document on the server.
It is used only for the technical purposes
ErrorDetected
Property
Gets information about the error detected in the performance last command.
If the Instance object does not indicate to the real instance object then this property is true. Also objects of this class contains IsVoid property for identification of instances’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)
{
// if error detected then return -1
if (instance.ErrorDetected) return -1;
// 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)
{
// if error detected then return -1
if ($instance->ErrorDetected) return -1;
// clear cookie
$instance->ClearCookie();
// go to lessons.zennolab.com
$tab = $instance->ActiveTab;
if (($tab->sVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
return 0;
}AllTabs
Property
Gets the all open tabs.
Example
// get all tabs
Tab[] tabs = instance.AllTabs;Example2
// get all tabs
$tabs = $instance->AllTabs;MainTab
Property
Gets the main tab. The tab with name “page” or last created.
Example
// get main tab
Tab mainTab = instance.MainTab;Example2
// get main tab
$mainTab = $instance->MainTab;ActiveTab
Property
Gets the active tab.
Example
// get active tab
Tab activeTab = instance.ActiveTab;Example2
// get active tab
$activeTab = $instance->ActiveTab;ActiveExtension
Property
Gets the active extension.
Example
// get active extension
Tab activeExtension = instance.ActiveExtension;Example2
// get active extension
activeExtension = $instance->ActiveExtension;IsExtensionWorking
Property
Gets a value that indicates whether extension activated (working).
LoadPictures
Property
Gets or sets a value that indicates whether loading picture from server are allowed.
FormTitle
Property
Gets the parent form title
AllowPopUp
Property
Gets or sets a value that indicates whether popups are allowed.
AllowScriptError
Property
Gets or sets a value that indicates whether script error are allowed.
BackGroundSoundsPlay
Property
Gets or sets a value that indicates whether play background sounds associated with the document are allowed.
DownloadActiveX
Property
Gets or sets a value that indicates whether to download ActiveX controls are allowed.
DownloadFrame
Property
Gets or sets a value that indicates whether download contents of frames are allowed.
UseJavaApplets
Property
Gets or sets a value that indicates whether to run Java applets are allowed.
UsePlugins
Property
Gets or sets a value that indicates whether to run Plugins are allowed.
UseMedia
Property
Gets or sets a value that indicates whether to use media content are allowed.
RunActiveX
Property
Gets or sets a value that indicates whether to run on the execution of ActiveX controls are allowed.
UseJavaScripts
Property
Gets or sets a value that indicates whether use of Java scripts are allowed.
UseCSS
Property
Gets or sets a value that indicates whether use of CSS are allowed.
UseAdds
Property
Gets or sets a value that indicates whether blocks adds.
UsePluginsForceWmode
Property
Gets or sets a value that indicates whether use of Java scripts are allowed.
ForceTouch
Property
Gets or sets a value that indicates whether user’s manual mouse input must be replaced with touch events.
UseBrowserWithoutContent
Property
Gets or sets a value that indicates whether show content of the browser.
DownloadVideos
Property
Gets or sets a value that indicates whether download videos contained in the document are allowed.
DownloadsPath
Property
Gets or sets the path for downloads.
EmulationLevel
Property
Gets or sets the current emulation level.
ScreenResolution
Property
Gets the screen resolution.
IgnoreAjaxRequests
Property
Gets or set the information about ignoring ajax requests.
IgnoreFlashRequests
Property
Gets or set the information about ignoring flash requests.
IgnoreAdditionalRequests
Property
Gets or set the information about ignoring additional requests.
IgnoreFrameRequests
Property
Gets or set the information about ignoring frame requests.
SymbolEmulationDelay
Property
Gets or sets the symbol emulation delay.
FieldEmulationDelay
Property
Gets or sets the field emulation delay.
ScreenOrientation
Property
Gets or set the screen orientation.
AudioPreferences
Property
Gets the AudioPreferences object that allows you to edit audio settings.
Example
// set Chrome useragent
instance.SetHeader(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.UserAgent, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36");
// set audio context params
instance.AudioPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.AudioPreference.AudioContextState, "running"); // string value, can take values "suspended", "running" or "closed"
instance.AudioPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.AudioPreference.BaseLatency, "0.02"); // double value, visible if Chrome useragent is set
instance.AudioPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.AudioPreference.MaxChannelCount, "10"); // int value
instance.AudioPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.AudioPreference.SampleRate, "96000"); // int value
instance.AudioPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.AudioPreference.SmoothingTimeConstant, "0.65"); // double value, can take values from 0 to 1WebGLPreferences
Property
Gets the WebGLPreferences object that allows you to edit webgl settings.
Example
// set Chrome useragent
instance.SetHeader(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.UserAgent, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36");
// set webgl context params
instance.WebGLPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.WebGLPreference.Renderer, "WebKit WebGL");
instance.WebGLPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.WebGLPreference.Vendor, "WebKit");
instance.WebGLPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.WebGLPreference.Version, "WebGL 1.0 (OpenGL ES 2.0 Chromium)");
instance.WebGLPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.WebGLPreference.ShadingLanguageVersion, "WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium)");
instance.WebGLPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.WebGLPreference.UnmaskedRenderer, "Google Inc.");
instance.WebGLPreferences.Set(ZennoLab.InterfacesLibrary.Enums.Browser.WebGLPreference.UnmaskedVendor, "ANGLE (NVIDIA GeForce GT 630 Direct3D11 vs_5_0 ps_5_0)");UrlManipulation
Property
Gets or set the information about url manipulation.
IsWaitingUserAction
Property
Gets the instance is waiting user action or not.
LastDownloadedFile
Property
Gets the path of the last downloaded file.
UseGeoposition
Property
Gets or sets a value that indicates whether to use geoposition are allowed.
CanvasRenderMode
Property
Gets or set the information about canvas render mode.
Example
instance.CanvasRenderMode = ZennoLab.InterfacesLibrary.Enums.Browser.CanvasMode.Emulate;
instance.CanvasRenderSeed = "5caf24ded0e11f4a29a3ba236152c4d1";CanvasMissMode
Property
Gets or set the information about canvas render mode after SuperEmulation fails
Example
instance.CanvasRenderMode = ZennoLab.InterfacesLibrary.Enums.Browser.CanvasMode.SuperEmulation;
instance.CanvasMissMode = ZennoLab.InterfacesLibrary.Enums.Browser.CanvasMissModeEnum.Emulate;
instance.CanvasRenderSeed = "5caf24ded0e11f4a29a3ba236152c4d1";CanvasRenderSeed
Property
Gets or set the seed string for generating fake canvas. Canvas emulation works only if CanvasRenderMode sets to Emulate.
Example
instance.CanvasRenderMode = ZennoLab.InterfacesLibrary.Enums.Browser.CanvasMode.Emulate;
instance.CanvasRenderSeed = "5caf24ded0e11f4a29a3ba236152c4d1";TimezoneWorkMode
Property
Gets or set the information about time zone working mode.
Example
instance.TimezoneWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.TimezoneMode.Emulate;AudioContextMode
Property
Gets or set the information about audio context work mode.
Example
instance.AudioContextMode = ZennoLab.InterfacesLibrary.Enums.Browser.AudioMode.Emulate;
instance.AudioContextSeed = "0.0004817737;0.0008047798";AudioContextSeed
Property
Gets or set the seed string for generating fake audio context. AudioContext emulation works only if AudioContextMode sets to Emulate
Example
instance.AudioContextMode = ZennoLab.InterfacesLibrary.Enums.Browser.AudioMode.Emulate;
instance.AudioContextSeed = "0.0004817737;0.0008047798";ClientRectWorkMode
Property
Gets or set the information about client rect work mode.
Example
instance.ClientRectWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.ClientRectMode.Emulate;
instance.ClientRectSeed = "9.957216E-06;3.87007E-06";ClientRectSeed
Property
Gets or set the seed string for generating fake client rect. ClientRect emulation works only if ClientRectWorkMode sets to Emulate
Example
instance.ClientRectWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.ClientRectMode.Emulate;
instance.ClientRectSeed = "9.957216E-06;3.87007E-06";WebRTCWorkMode
Property
Gets or set the information about webrtc working mode. The property needs isolated process, because it is applied to all instances in the process.
Example
instance.WebRTCWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.WebRTCMode.Emulate;
instance.SetWebRTCAdresses("127.0.0.1");UseTrafficMonitoring
Property
Gets or sets a value that indicates whether use detailed traffic monitoring.
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");FontsFolder
Property
Gets or sets path of additional fonts folder. The fonts from the folder may be used for ShowFont/HideFont methods.
ProfilePath
Property
Gets path of profile for instance.
CachePath
Property
Gets path of cache for instance.
UsesFolderProfile
Property
Gets whether instance uses folder profile on disk or not.
BrowserType
Property
Gets the type of browser.
UseToStringEmulation
Property
Gets or sets a value that indicates whether use javascript toString() emulation.
UseJsFeatures
Property
Gets or sets a value that indicates whether use javascript features.
UseFullMouseEmulation
Property
Gets or sets a value that indicates whether use full mouse emulation features where it posible.
AllowNotification
Property
Gets or sets a value that indicates whether allow browser notification.
LastNotificationTitle
Property
Gets the last notification title of the browser.
ClearTrafficWhenNavigate
Property
Gets or sets whether the traffic items are to be cleared when navigating.
LastNotificationText
Property
Gets the last notification text of the browser.
AutoRetry
Property
Gets or sets a value that indicates whether retry requests. Works only in Chrome.
AutoRetryMaxAttempts
Property
Gets or set retry requests attempts. Works only in Chrome.
AutoRetry5xxResponses
Property
Gets or sets a value that indicates whether retry requests with response code 5xx. Works only in Chrome.
FrameRate
Property
Gets or set frame rate of the browser. Works only in Chrome.
AnimationFrameRate
Property
Gets or set animation frame rate of the browser. Works only in Chrome.
NavigatorPermissions
Property
Sets or gets a JSON document, which is a config for permissions statuses provided by the Permissions API. Defaults are used the same as chrome.
SpeechSynthesisVoices
Property
Sets or gets a JSON document, which is a config for voices in the Speech Synthesis API
DevicePixelRatio
Property
Get or set device pixel ratio of the browser. Works only in Chrome.
WsConnectionString
Property
Gets the websocket connection string for Chromium browser.
NavigateErrorCountRunning
Property
Gets or sets the count of the detected navigation errors.
Methods
ClearCookie
Method
Clears the cookies.
Parameters
| Параметр | Описание |
|---|---|
domainFilter | The regular expressions for filtering by domain. If value is null or empty string, then method clears cookies for all domains. The default value is empty string. |
Example
// clear cookie
instance.ClearCookie();Example2
// clear cookie
$instance->ClearCookie();ClearCache
Method
Clears the cache.
Parameters
| Параметр | Описание |
|---|---|
domainFilter | The regular expressions for filtering by domain. If value is null or empty string, then method clears caches for all domains. The default value is empty string. |
storeCookie | The true if need to store the cookies; otherwise false. |
Example
// clear cache
instance.ClearCache();Example2
// clear cache
$instance->ClearCache();SwitchPopupHandlerMode
Method
Reserved function
NewTab
Method
Creates a new tab in the current instance.
Parameters
| Параметр | Описание |
|---|---|
address | The header of a new tab. |
Returns: A new tab in the current instance.
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();
// create a new tab and go to zennolab.com
tab = instance.NewTab("zennolab");
tab.Navigate("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();
// create a new tab and go to zennolab.com
$tab = $instance->NewTab("zennolab");
$tab->Navigate("zennolab.com", "");
if ($tab->IsBusy) $tab->WaitDownloading();
return 0;
}GetTabByAddress
Method
Returns tab by the address.
“page” - this is the default value for main tab. For popup uses the address “popup”.
Parameters
| Параметр | Описание |
|---|---|
address | The address of tab in the Instance object. |
Returns: The tab of the Instance object with the necessary address.
Example
// get tab by address
Tab tab = instance.GetTabByAddress("page");Example2
// get tab by address
$tab = $instance->GetTabByAddress("page");ReleasePreparing
Method
Prepare before release instance.
CloseAllTabs
Method
Closes all tabs except the main tab.
Example
// close all tabs
instance.CloseAllTabs();Example2
// close all tabs
$instance->CloseAllTabs();SetOkAlertPolicy
Method
Sets the policy for pop-up Alert windows with one-click OK.
Parameters
| Параметр | Описание |
|---|---|
answer | The answer for the window. |
id | The id of project. The default value is empty string. |
SetOkCancelConfirmPolicy
Method
Sets the policy for pop-up windows Confirm with OK and Cancel.
Parameters
| Параметр | Описание |
|---|---|
answer | The answer for the window of the authorization. This parameter can take the following values: “ok” or “cancel”. |
id | The id of project. The default value is empty string. |
SetCertificate
Method
Sets the certificate to browser.
Parameters
| Параметр | Описание |
|---|---|
path | The path of certificate, witch extension is “.p12” or “.pfx”. |
pass | The password for certificate. |
SetJSValuePromptPolicy
Method
Sets the policy for pop-up Prompt windows with an input field value.
Parameters
| Параметр | Описание |
|---|---|
answer | The answer for the window of the authorization. This parameter can take the following values: “ok” or “cancel”. |
value | The value of the answer. |
id | The id of project. The default value is empty string. |
SetFileUploadPolicy
Method
Sets the policy for the windows of to send the file to the server.
Parameters
| Параметр | Описание |
|---|---|
answer | The answer for the window of the authorization. This parameter can take the following values: “ok” or “cancel”. |
value | The value of the answer. |
id | The id of project. The default value is empty string. |
SetAuthorizationPolicy
Method
Sets the policy for the windows of the authorization.
Parameters
| Параметр | Описание |
|---|---|
answer | The answer for the window of the authorization. This parameter can take the following values: “ok” or “cancel”. |
login | The login for the window of the authorization. |
pass | The password for the window of the authorization. |
id | The id of project. The default value is empty string. |
SetCertificatesPolicy
Method
Sets the policy for the window of making the certificate.
Parameters
| Параметр | Описание |
|---|---|
answer | The answer for the window. |
id | The id of project. The default value is empty string. |
SetDefaultPreference
Method
Sets the all the default settings.
Parameters
| Параметр | Описание |
|---|---|
id | The id of project. The default value is empty string. |
Example
instance.SetDefaultPreference();Example2
$instance->SetDefaultPreference();SetProxy
Method
Sets the proxy to the instance.
The parameters login and password can be empty if authorization is not necessary.
Parameters
| Параметр | Описание |
|---|---|
ip | The IP address for the proxy. |
port | The port for the instance. |
type | The type of proxy. It’s can be http, socks4 or socks5 |
login | The login for authorization. |
password | The password for authorization. |
useProxifier | The true if use proxifier; otherwise and default, false. |
emulateGeolocation | The true if need emulate geolocation according with the ip, but the accuracy will be generated randomly from 50 meters to 20 kilometers; otherwise and default, false. |
emulateTimezone | The true if need emulate timezone according with the ip; otherwise and default, false. |
emulateWebrtc | The true if need emulate webrtc addresses according with the ip; otherwise and default, false. |
Example
public static int Execute(Instance instance)
{
instance.ClearCookie();
instance.ClearProxy();
instance.SetProxy("174.59.74.190", 1686, "http", "", "");
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)
{
$instance->ClearCookie();
$instance->ClearProxy();
$instance->SetProxy("174.59.74.190", "http", "", "");
$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;
}SetProxy
Method
Sets the proxy to the instance.
Parameters
| Параметр | Описание |
|---|---|
proxyString | The parameters of proxy. This string should has the follow format: [protocol://](login):(password)@:(port). For example: socks5://192.168.0.1:80 |
useProxifier | The true if use proxifier; otherwise and default, false. |
emulateGeolocation | The true if need emulate geolocation according with the ip; otherwise and default, false. |
emulateTimezone | The true if need emulate timezone according with the ip; otherwise and default, false. |
emulateWebrtc | The true if need emulate webrtc addresses according with the ip; otherwise and default, false. |
Example
public static int Execute(Instance instance)
{
instance.ClearCookie();
instance.ClearProxy();
instance.SetProxy("http://174.59.74.190:1686");
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(e$instance)
{
$instance->ClearCookie();
$instance->ClearProxy();
$instance->SetProxy("http://174.59.74.190:1686");
$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;
}SetProxy
Method
Sets the proxy and network settings to the instance.
Null params do not reset proxy or network settings. To reset NetworkSettings, call the method with empty class instannces. “networkSettings” - available only in Chromium.
Parameters
| Параметр | Описание |
|---|---|
proxySettings | Class of proxy parameters |
networkSettings | Class of network settings parameters |
Example
public static int Execute(Instance instance)
{
instance.ClearCookie();
instance.ClearProxy();
instance.SetProxy(new ProxySettings("http://174.59.74.190:1686"), new NetworkSettings(true, "https://cloudflare-dns.com/dns-query{?dns} https://dns.google/dns-query{?dns}")
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;
}
/// The following code example demonstrates uses of theExample
public static int Execute(Instance instance)
{
instance.ClearCookie();
// reset proxy
instance.ClearProxy();
// reset NetworkSettings
instance.SetProxy(null, new NetworkSettings());
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;
}SetHeader
Method
Sets the header for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Параметр | Описание |
|---|---|
headerName | The header name. |
value | The header value. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// set header
instance.SetHeader("HTTP_USER_AGENT", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; ZennoPoster)");
// 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)
{
// set header
$instance->SetHeader("HTTP_USER_AGENT", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; ZennoPoster)");
// 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;
}SetHeader
Method
Sets the header for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Параметр | Описание |
|---|---|
field | The header name. |
value | The header value. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// set header
instance.SetHeader(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.UserAgent, "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; ZennoPoster)");
// 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)
{
// set header
$instance->SetHeader(ZennoLab\InterfacesLibrary\Enums\Browser\NavigatorField::UserAgent, "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; ZennoPoster)");
// 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;
}SetUserHeader
Method
Sets the user header for tabs requests.
The method call is made before calling any other methods of an Instance object.
Parameters
| Параметр | Описание |
|---|---|
headerName | The header name. |
value | The header value. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// set header
instance.SetHeader("X-Forwarded-For", "123.34.5.78");
// 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)
{
// set header
$instance->SetHeader("X-Forwarded-For", "123.34.5.78");
// 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;
}ShowNavigatorField
Method
Show navigator field for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Параметр | Описание |
|---|---|
field | The field name. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// set header
instance.ShowNavigatorField(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.JavaEnabled);
// 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("whoer.net", "");
if (tab.IsBusy) tab.WaitDownloading();
return 0;
}ShowNavigatorField
Method
Show navigator field for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Параметр | Описание |
|---|---|
field | The field name. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// set header
instance.ShowNavigatorField("javaEnabled");
// 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("whoer.net", "");
if (tab.IsBusy) tab.WaitDownloading();
return 0;
}HideNavigatorField
Method
Hide navigator field for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Параметр | Описание |
|---|---|
field | The field name. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// set header
instance.HideNavigatorField(ZennoLab.InterfacesLibrary.Enums.Browser.NavigatorField.JavaEnabled);
// 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("whoer.net", "");
if (tab.IsBusy) tab.WaitDownloading();
return 0;
}HideNavigatorField
Method
Hide navigator field for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Параметр | Описание |
|---|---|
field | The field name. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// set header
instance.HideNavigatorField("javaEnabled");
// 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("whoer.net", "");
if (tab.IsBusy) tab.WaitDownloading();
return 0;
}GetPlugins
Method
Returns a collection of current visible plugins.
Returns: Collection of plugins.
Example
// get plugins
var plugins = instance.GetPlugins();
// name of first plugin
string name = "";
if (plugins != null)
{
var pluginsList = plugins.ToList();
if(pluginsList.Count > 0)
{
name = pluginsList[0].Name;
}
}ShowPlugin
Method
Show the plugin.
Parameters
| Параметр | Описание |
|---|---|
plugin | Plugin object for showing. If it not exist in plugins collection, it will be added to colllection. |
Example
// create plugin item
var plugin = new ZennoLab.CommandCenter.PluginItem("Plugin name", "PluginFile.dll", "It is description of plugin", "15.0.0.3");
// add and show plugin
instance.ShowPlugin(plugin);HidePlugin
Method
Hide the plugin.
Parameters
| Параметр | Описание |
|---|---|
plugin | Plugin object for hiding. |
Example
// create plugin item
var plugin = new ZennoLab.CommandCenter.PluginItem("Plugin name", "PluginFile.dll", "It is description of plugin", "15.0.0.3");
// hide plugin
instance.HidePlugin(plugin);LoadPlugins
Method
Loads plugins.
Parameters
| Параметр | Описание |
|---|---|
path | The path to plugins. |
Example
// load plugins
instance.LoadPlugins("path");Example2
// load plugins
$instance->LoadPlugins("path");LoadPlugins
Method
Loads plugins.
Parameters
| Параметр | Описание |
|---|---|
plugins | The plugins data. |
SavePlugins
Method
Saves plugins.
Parameters
| Параметр | Описание |
|---|---|
path | The path to plugins. |
Example
// save plugins
instance.SavePlugins("path");Example2
// save plugins
$instance->SavePlugins("path");SavePlugins
Method
Saves plugins.
Returns: The path to plugins.
LoadLocalStorage
Method
Loads local storage.
Parameters
| Параметр | Описание |
|---|---|
path | The path to local storage data. |
Example
// load local storage
instance.LoadLocalStorage("path");Example2
// load local storage
$instance->LoadLocalStorage("path");LoadLocalStorage
Method
Loads local storage.
Parameters
| Параметр | Описание |
|---|---|
storage | The local storage data. |
SaveLocalStorage
Method
Saves local storage.
Parameters
| Параметр | Описание |
|---|---|
path | The path to local storage data. |
Example
// save local storage
instance.SaveLocalStorage("path");Example2
// save local storage
$instance->SaveLocalStorage("path");SaveLocalStorage
Method
Saves local storage.
Returns: The local storage data.
HeadersToDefault
Method
Sets all headers to default.
GetProxy
Method
Returns a proxy of the Instance object.
If a proxy is not used, then the result is “noproxy”
Returns: Contains a string of the form “ip:port:isSocks”
Example
// get proxy
string proxy = instance.GetProxy();
// if instance has proxy
if (proxy != "noproxy")
{
// split string
string[] args = proxy.Split(':');
// first is id
string ip = args[0];
// second is port
int port = Convert.ToInt32(args[1]);
// third is socks or not
bool s = Convert.ToBoolean(args[2]);
}Example2
// get proxy
$proxy = $instance->GetProxy();
// if instance has proxy
if ($proxy != "noproxy")
{
// split string
$args = $proxy->Split(':');
// first is id
$ip = $args[0];
// second is port
$port = System\Convert::ToInt32($args[1]);
// third is socks or not
$s = System\Convert::ToBoolean($args[2]);
}ClearProxy
Method
Removes the proxy from the Instance object.
Example
// clear proxy
instance.ClearProxy();Example2
// clear proxy
$instance->ClearProxy();GetTemplateValue
Method
Returns the value of a branch in the template for the specified step.
Parameters
| Параметр | Описание |
|---|---|
stepId | Id of step. |
branchName | The branch name. |
Returns: The value of a branch.
SetTemplateValue
Method
Sets the value of a branch in the template for the specified step.
Parameters
| Параметр | Описание |
|---|---|
stepId | Id of the step. |
branchName | The branch name. |
value | The value to set. |
RiseMacros
Method
Executes the specified macros with parameters.
Full description of macros can be found here: Macros.
Parameters
| Параметр | Описание |
|---|---|
macrosType | The type of macros. |
parameters | An array of parameters for macros. |
Returns: The result of the macros. If the value is empty string then an error at runtime.
Example
public static int Execute(Instance instance)
{
instance.ClearCookie();
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();
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByName("text");
string result = instance.RiseMacros("Person.FirstName", new [] { "eng", "male" });
he.SetValue(result, true);
return 0;
}Example2
public static function Execute($instance)
{
$instance->ClearCookie();
$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();
$he = $instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByName("text");
$result = $instance->RiseMacros("Person.FirstName", array("eng", "male"));
$he->SetValue($result, true);
return 0;
}EvaluateJavaScript
Method
Evaluates localy the specified java script code (supports WSH objects).
Parameters
| Параметр | Описание |
|---|---|
javaScript | The specified java script string to evaluate. |
Returns: The result of the evaluation. If the value is empty string then an error at runtime.
RiseMacros
Method
Executes the specified macros.
Full description of macros can be found here: Macros.
Parameters
| Параметр | Описание |
|---|---|
macros | The macros as a string in the following format: {-MacrosType- |
Returns: The result of the macros. If the value is empty string then an error at runtime.
Example
public static int Execute(Instance instance)
{
instance.ClearCookie();
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();
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByName("text");
string result = instance.RiseMacros("{-Person.FirstName-|-eng-|-male-}");
he.SetValue(result, true);
return 0;
}Example2
public static function Execute($instance)
{
$instance->ClearCookie();
$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();
$he = $instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByName("text");
$result = $instance->RiseMacros("{-Person.FirstName-|-eng-|-male-}");
$he->SetValue($result, true);
return 0;
}Reload
Method
Reloads the current Instance object. Works only in ProjectMaker and ZennoPoster.
Launch
Method
Launches the instance with required built-in browser type. Works in ProjectMaker and ZennoPoster.
Parameters
| Параметр | Описание |
|---|---|
browserType | The required type of browser to launch. |
useProfile | The true if need to use the current profile; otherwise false. |
Example
instance.Launch(ZennoLab.InterfacesLibrary.Enums.Browser.BrowserType.WithoutBrowser, true);Launch
Method
Launches the instance with required built-in browser type and browser arguments. Works in ProjectMaker and ZennoPoster.
Parameters
| Параметр | Описание |
|---|---|
browserType | The required type of browser to launch. |
browserArgs | The command line arguments for starting browser. |
useProfile | The true if need to use the current profile; otherwise false. |
Launch
Method
Launches the instance with required built-in browser type, browser arguments and folder-profile. Works in ProjectMaker and ZennoPoster.
Parameters
| Параметр | Описание |
|---|---|
browserType | The required type of browser to launch. |
browserArgs | The command line arguments for starting browser. |
cachePath | Path to the folder-profile folder. |
Launch
Method
Launches the instance with required built-in browser type, browser arguments and folder-profile. Works in ProjectMaker and ZennoPoster.
Parameters
| Параметр | Описание |
|---|---|
browserType | The required type of browser to launch. |
browserArgs | The command line arguments for starting browser. |
cachePath | Path to the folder-profile folder. |
convertProfileFolder | Convert CEF profile folder to Chromium profile folder. |
IntegrationLaunch
Method
Launches integtated instance. Works in ProjectMaker and ZennoPoster.
Parameters
| Параметр | Описание |
|---|---|
profileId | The profile identifier in ZennoBrowser. |
Example
// Launch integrated browser
instance.IntegrationLaunch(project.Variables["id"].Value);IntegrationLaunch
Method
Launches integtated instance. Works in ProjectMaker and ZennoPoster.
Parameters
| Параметр | Описание |
|---|---|
profileId | The profile identifier in ZennoBrowser. |
workspaceId | The workspace identifier in ZennoBrowser. |
Example
// Launch integrated browser
instance.IntegrationLaunch(project.Variables["profileId"].Value, project.Variables["workspaceId"].Value);Launch
Method
Launches the instance with settings object, allow to launch any browser type. Works in ProjectMaker and ZennoPoster.
Parameters
| Параметр | Описание |
|---|---|
launchSettings | The settings of browser launch. |
Example
// Launch build-in Chromium with settings
{
var settings = (ZennoLab.CommandCenter.Classes.BuiltInBrowserLaunchSettings)
ZennoLab.CommandCenter.Classes.BrowserLaunchSettingsFactory.Create(
ZennoLab.InterfacesLibrary.Enums.Browser.BrowserType.Chromium);
settings.BrowserArgs = "--your-arg1 --your-arg2=value";
settings.CachePath = Path.Combine(project.Directory, "TestProfilePath");
settings.ConvertProfileFolder = true;
settings.UseProfile = true;
instance.Launch(settings);
}
// Launch integrated browser
{
var settings = (ZennoLab.CommandCenter.Classes.IntegratedBrowserLaunchSettings)
ZennoLab.CommandCenter.Classes.BrowserLaunchSettingsFactory.Create(
ZennoLab.InterfacesLibrary.Enums.Browser.BrowserType.ChromiumFromZB);
settings.IntegrationProfileId = new ZennoLab.CommandCenter.Classes.IntegrationProfileId()
{
ProfileId = project.Variables["id"].Value
};
// Override proxy for profile
settings.ProxyOptions = new ZennoLab.CommandCenter.Classes.IntegrationProxyOptions()
{
ProxyOverride = project.Variables["proxy"].Value,
ProxyUsageKind = ZennoLab.InterfacesLibrary.Enums.Integration.IntegrationProxyUsageKind.OverrideProxyString
};
instance.Launch(settings);
}Stop
Method
Stops the instance. Works in ProjectMaker and ZennoPoster.
Example
instance.Stop();SaveCookie
Method
Saves cookie.
Parameters
| Параметр | Описание |
|---|---|
path | The path to cookie. |
Example
// save cookie
instance.SaveCookie("path");Example2
// save cookie
$instance->SaveCookie("path");SaveCookie
Method
Saves cookie.
Returns: The cookies data.
Example
// get byte array of cookie
byte[] cookieBytes = instance.SaveCookie();
// convert byte array to string and return result
return System.Text.Encoding.UTF8.GetString(cookieBytes);Example2
// get byte array of cookie
cookieBytes = instance.SaveCookie();
// convert byte array to string and return result
return System.Text.Encoding.UTF8.GetString(cookieBytes);LoadCookie
Method
Loads cookie.
Parameters
| Параметр | Описание |
|---|---|
path | The path to cookie. |
Example
// load cookie
instance.LoadCookie("path");Example2
// load cookie
$instance->LoadCookie("path");LoadCookie
Method
Loads cookie.
Parameters
| Параметр | Описание |
|---|---|
cookie | The cookies data. |
Example
// format cookie string
string cookie = @".samy.pl TRUE / FALSE 05/18/2033 06:33:20 __utmc 27102015 FALSE TRUE
samy.pl FALSE /evercookie/ FALSE 05/18/2033 06:33:20 evercookie_png 398 FALSE TRUE";
// convert cookie string to byte array
byte[] cookieBytes = System.Text.Encoding.UTF8.GetBytes(cookie);
// load cookie
instance.LoadCookie(cookieBytes);Example2
// format cookie string
$cookie = @".samy.pl TRUE / FALSE 05/18/2033 06:33:20 __utmc 27102015 FALSE TRUE
samy.pl FALSE /evercookie/ FALSE 05/18/2033 06:33:20 evercookie_png 398 FALSE TRUE";
// convert cookie string to byte array
$cookieBytes = System\Text\Encoding\UTF8::GetBytes($cookie);
// load cookie
$instance->LoadCookie($cookieBytes);SetCookie
Method
Sets cookie.
Parameters
| Параметр | Описание |
|---|---|
cookie | The cookies data in format “Host\tDomainFlag\tPath\tSecureFlag\tExpiry\tName\tValue\tHttpOnlyFlag\tSessionFlag\r\n …” for Firefox and “Host\tDomainFlag\tPath\tSecureFlag\tExpiry\tName\tValue\tHttpOnlyFlag\tSessionFlag\tSameSite\tPriority\r\n …” for Chrome. |
Example
// format cookie string
string cookie = @".samy.pl TRUE / FALSE 05/18/2033 06:33:20 __utmc 27102015 FALSE TRUE
samy.pl FALSE /evercookie/ FALSE 05/18/2033 06:33:20 evercookie_png 398 FALSE TRUE";
// load cookie
instance.SetCookie(cookie);Example2
// format cookie string
$cookie = @".samy.pl TRUE / FALSE 05/18/2033 06:33:20 __utmc 27102015 FALSE TRUE
samy.pl FALSE /evercookie/ FALSE 05/18/2033 06:33:20 evercookie_png 398 FALSE TRUE";
// load cookie
$instance->SetCookie($cookie);GetCookie
Method
Gets cookie.
Parameters
| Параметр | Описание |
|---|---|
domain | The domain of cookie. The default value is empty string. |
isCookieFormat | The true, if need format of cookie “name1=value1; name2=value2; …”, otherwise false. The default value is false. The default format is “Host\tDomainFlag\tPath\tSecureFlag\tExpiry\tName\tValue\tHttpOnlyFlag\tSessionFlag\r\n …” for Firefox and “Host\tDomainFlag\tPath\tSecureFlag\tExpiry\tName\tValue\tHttpOnlyFlag\tSessionFlag\tSameSite\tPriority\r\n …” for Chrome. |
Returns: The cookies in the string format.
Example
instance.ActiveTab.Navigate("http://google.com/");
instance.ActiveTab.WaitDownloading();
// get cookie by domain
return instance.GetCookie("google.com", true);Example2
$instance->ActiveTab->Navigate("http://google.com/");
$instance->ActiveTab->WaitDownloading();
// get cookie by domain
return $instance->GetCookie("google.com", true);SetFilesForUpload
Method
Sets the files for upload.
Parameters
| Параметр | Описание |
|---|---|
files | The paths of files for upload |
FindElementByIntelliSearch
Method
Searches for an HTML element using IntelliSearch technology, and returns the first or the most appropriate occurrence.
The parameters form and elementClass can be name on one of supported languages or id from current IntelliSearch base. IntelliSearch not depend not on the language or the version of the program. IntelliSearch is a multi-language system. However, depends on the current versions of the standard base and additional base (user base). Currently supports two languages: English and Russian. Do not forget that before using IntelliSearch must choose one of the standard base. Also the name of a class of elements and forms may vary in different versions of the base. The case of strings does not matter. The parameter isBlocked should use if need find html element which was used by IntelliSearch. After using of the element, IntelliSearch marks html element as a blocked and ignores it in followings searching. If need find element among all or among the blocked then isBlocked should be true; otherwise false.
Parameters
| Параметр | Описание |
|---|---|
form | The form for searching. It’s can be name on one of supported languages or id from current IntelliSearch base. |
elementClass | The class of element for searching. It’s can be name on one of supported languages or id from current IntelliSearch base. |
isLink | The true if are searching html link; otherwise false. In case then isLink is true, parameter “form” can be empty. It’s not error if “form” not empty, however this parameter is not used. |
inBlocked | The true if allowed to search among the locked html elements; otherwise false. |
Returns: The element found by the search.
Example
// clear cookie
instance.ClearCookie();
// navigate to lessons.zennolab.com
instance.ActiveTab.Navigate("lessons.zennolab.com", "");
// waiting for downloading
instance.ActiveTab.WaitDownloading();
// find link by IntelliSearch
HtmlElement he = instance.FindElementByIntelliSearch("", "Simple registration", true, false);
// if html element found
if (!he.IsVoid)
{
// click on link
he.RiseEvent("click", "Full");
}
// find password field
he = instance.FindElementByIntelliSearch("Registration", "Password", false, false);
// if html element found
if (!he.IsVoid)
{
// set value
he.SetValue("password", "Full", false);
}
// find password field again in blocked
he = instance.FindElementByIntelliSearch("Registration", "Password", false, true);
// if html element found
if (!he.IsVoid)
{
// get value
return he.GetValue(false);
}Example2
// clear cookie
$instance->ClearCookie();
// navigate to lessons.zennolab.com
$instance->ActiveTab->Navigate("lessons.zennolab.com", "");
// waiting for downloading
$instance->ActiveTab->WaitDownloading();
// find link by IntelliSearch
$he = $instance->FindElementByIntelliSearch("", "Simple registration", true, false);
// if html element found
if (!$he->IsVoid)
{
// click on link
$he->RiseEvent("click", "Full");
}
// find password field
$he = $instance->FindElementByIntelliSearch("Registration", "Password", false, false);
// if html element found
if (!$he->IsVoid)
{
// set value
$he->SetValue("password", "Full", false);
}
// find password field again in blocked
$he = $instance->FindElementByIntelliSearch("Registration", "Password", false, true);
// if html element found
if (!$he->IsVoid)
{
// get value
return $he->GetValue(false);
}SendText
Method
Emulates the typing.
Parameters
| Параметр | Описание |
|---|---|
text | The text for typing. |
latency | The latency between the input characters of text. |
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();
// try find textarea
HtmlElement he = instance.ActiveTab.MainDocument.Body.FindChildByTag("textarea", 0);
// if html element is not empty
if (!he.IsVoid && !he.IsNull)
{
// focus on this element
he.Focus();
// send text
instance.SendText("It's just simple text for typing. Look at the textarea element and you can see this text.", 200);
}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();
// try find textarea
$he = $instance->ActiveTab->MainDocument->Body->FindChildByTag("textarea", 0);
// if html element is not empty
if (!$he->IsVoid && !$he->IsNull)
{
// focus on this element
$he->Focus();
// send text
$instance->SendText("It's just simple text for typing. Look at the textarea element and you can see this text.", 200);
}Click
Method
Emulates a click on specified area.
The emulation of click made only on the active tab.
Parameters
| Параметр | Описание |
|---|---|
xMin | minimum x coordinate. |
xMax | maximum x coordinate. |
yMin | minimum y coordinate. |
yMax | maximum y coordinate. |
clickType | The mouse button type. It can have a value “Left”, “Right”, “DoubleClick”. |
clickDistributionType | The click distribution type. It can have a value “Normal”, “Random”. |
Example
// navigate to lessons.zennolab.com
instance.ActiveTab.Navigate("lessons.zennolab.com", "");
// waiting for page loading
instance.ActiveTab.WaitDownloading();
// emulation of click
instance.Click(100, 100, 200, 200, "Left", "Normal");Example2
// navigate to lessons.zennolab.com
$instance->ActiveTab->Navigate("lessons.zennolab.com", "");
// waiting for page loading
$instance->ActiveTab->WaitDownloading();
// emulation of click
$instance->Click(100, 100, 200, 200, "Left", "Normal");IntelliSearchSetBase
Method
Sets base of IntelliSearch.
Parameters
| Параметр | Описание |
|---|---|
revision | The revision of base. |
path | |
password | The password |
IntelliSearchSetAdditionalBase
Method
Sets additional base of IntelliSearch.
Parameters
| Параметр | Описание |
|---|---|
path | The path to the additional base. |
Example
// set additional base of IntelliSearch
instance.IntelliSearchSetAdditionalBase("path");Example2
// set additional base of IntelliSearch
$instance->IntelliSearchSetAdditionalBase("path");SetWindowPreference
Method
Sets the window settings.
Parameters
| Параметр | Описание |
|---|---|
preference | The setting of window. |
value | The value of setting. |
SetWindowPreference
Method
Sets the window settings.
Parameters
| Параметр | Описание |
|---|---|
preference | The setting of window. |
value | The value of setting. |
SetScreenPreference
Method
Sets the screen settings.
Parameters
| Параметр | Описание |
|---|---|
preference | The setting of screen. |
value | The value of setting. |
SetScreenPreference
Method
Sets the screen settings.
Parameters
| Параметр | Описание |
|---|---|
preference | The setting of screen. |
value | The value of setting. |
SetWindowSize
Method
Sets the size of window.
Parameters
| Параметр | Описание |
|---|---|
width | The width of window. |
height | The height of window. |
WaitForUserAction
Method
Show instance window and wait for user action.
Parameters
| Параметр | Описание |
|---|---|
timeout | The timeout of waiting in seconds. |
Example
// wait for user action 5 minutes
instance.WaitForUserAction(300);Example2
// wait for user action 5 minutes
$instance->WaitForUserAction(300);WaitForUserAction
Method
Show instance window and wait for user action.
Parameters
| Параметр | Описание |
|---|---|
timeout | The timeout of waiting in seconds. |
comment | The comment shown when the browser appears. |
Example
// wait for user action 5 minutes
instance.WaitForUserAction(300);Example2
// wait for user action 5 minutes
$instance->WaitForUserAction(300);AddToTitle
Method
Add text to title of instance.
Parameters
| Параметр | Описание |
|---|---|
value | The text to add. |
GetContentPolicy
Method
Returns the content policy mode. It can have a value “DirectLoad”, “WhiteList”, “BlockList”.
Returns: The content policy mode for instance.
GetContentPolicyDomains
Method
Returns collection of domains texts for “WhiteList” or “BlockList” policy.
Returns: Collection of domains.
GetContentPolicyRegexs
Method
Returns collection of regexs for “WhiteList” or “BlockList” policy.
Returns: Collection of regexs.
SetContentPolicy
Method
Sets the policy for browser content.
Parameters
| Параметр | Описание |
|---|---|
policy | The type of policy. It can have a value “DirectLoad”, “WhiteList”, “BlockList”. |
domains | Collection of domains for “WhiteList” or “BlockList” policy. Default value is null. |
regexs | Collection of regular expressions for “WhiteList” or “BlockList” policy. Default value is null. |
Example
instance.SetContentPolicy("BlockList", new []{ "mc.yandex.ru" }, null);GetGeoposition
Method
Gets the geoposition coordinates.
Parameters
| Параметр | Описание |
|---|---|
latitude | The position’s latitude in decimal degrees. |
longitude | The position’s longitude in decimal degrees. |
accuracy | The accuracy of the latitude and longitude, expressed in meters. |
altitude | The position’s altitude in metres, relative to sea level. The default value is 0. |
altitudeAccuracy | The accuracy of the altitude expressed in meters. The default value is 0. |
heading | The direction in which the device is traveling. This value, specified in degrees, 0 degrees represents true north, and the direction is determined clockwise (which means that east is 90 degrees and west is 270 degrees). The default value is 0. |
speed | The velocity of the device in meters per second. The default value is 0. |
SetGeoposition
Method
Sets the geoposition coordinates and enables it for websites.
Parameters
| Параметр | Описание |
|---|---|
latitude | The position’s latitude in decimal degrees. |
longitude | The position’s longitude in decimal degrees. |
accuracy | The accuracy of the latitude and longitude, expressed in meters. |
altitude | The position’s altitude in metres, relative to sea level. The default value is 0. |
altitudeAccuracy | The accuracy of the altitude expressed in meters. The default value is 0. |
heading | The direction in which the device is traveling. This value, specified in degrees, 0 degrees represents true north, and the direction is determined clockwise (which means that east is 90 degrees and west is 270 degrees). The default value is 0. |
speed | The velocity of the device in meters per second. The default value is 0. |
SetCanvasEmulationSettings
Method
Set settings for SuperEmulation canvas render mode.
Parameters
| Параметр | Описание |
|---|---|
settings |
Example
instance.CanvasRenderMode = ZennoLab.InterfacesLibrary.Enums.Browser.CanvasMode.SuperEmulation;
instance.CanvasRenderSeed = "5caf24ded0e11f4a29a3ba236152c4d1";
instance.SetCanvasEmulationSettings(new CanvasEmulationSettings() { DropPotentialRandomlyAlgorithms = true });GetTimezone
Method
Gets the system timezone.
Parameters
| Параметр | Описание |
|---|---|
hours | The number of hours in the difference between the current time zone and UTC. |
minutes | The number of minutes in the difference between the current time zone and UTC. |
GetIanaTimezone
Method
Gets the system timezone.
Returns: The name of IANA region. If IANA region doesn’t set, will be returned string.Empty
SetTimezone
Method
Sets the system timezone.
Parameters
| Параметр | Описание |
|---|---|
hours | The number of hours in the difference between the current time zone and UTC. Possible values from -12 to 12. |
minutes | The number of minutes in the difference between the current time zone and UTC. Possible values from 0 to 60. The default value is 0. |
mode | Time zone working mode. |
Example
instance.SetTimezone(-4, 0); // UTC -04:00SetIanaTimezone
Method
Sets the system timezone.
The list of available IANA time zones: Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers Africa/Asmara Africa/Bamako Africa/Bangui Africa/Banjul Africa/Bissau Africa/Blantyre Africa/Brazzaville Africa/Bujumbura Africa/Cairo Africa/Casablanca Africa/Ceuta Africa/Conakry Africa/Dakar Africa/Dar_es_Salaam Africa/Djibouti Africa/Douala Africa/El_Aaiun Africa/Freetown Africa/Gaborone Africa/Harare Africa/Johannesburg Africa/Juba Africa/Kampala Africa/Khartoum Africa/Kigali Africa/Kinshasa Africa/Lagos Africa/Libreville Africa/Lome Africa/Luanda Africa/Lubumbashi Africa/Lusaka Africa/Malabo Africa/Maputo Africa/Maseru Africa/Mbabane Africa/Mogadishu Africa/Monrovia Africa/Nairobi Africa/Ndjamena Africa/Niamey Africa/Nouakchott Africa/Ouagadougou Africa/Porto-Novo Africa/Sao_Tome Africa/Tripoli Africa/Tunis Africa/Windhoek America/Adak America/Anchorage America/Anguilla America/Antigua America/Araguaina America/Argentina/Buenos_Aires America/Argentina/Catamarca America/Argentina/Cordoba America/Argentina/Jujuy America/Argentina/La_Rioja America/Argentina/Mendoza America/Argentina/Rio_Gallegos America/Argentina/Salta America/Argentina/San_Juan America/Argentina/San_Luis America/Argentina/Tucuman America/Argentina/Ushuaia America/Aruba America/Asuncion America/Atikokan America/Bahia America/Bahia_Banderas America/Barbados America/Belem America/Belize America/Blanc-Sablon America/Boa_Vista America/Bogota America/Boise America/Cambridge_Bay America/Campo_Grande America/Cancun America/Caracas America/Cayenne America/Cayman America/Chicago America/Chihuahua America/Coral_Harbour America/Costa_Rica America/Creston America/Cuiaba America/Curacao America/Danmarkshavn America/Dawson America/Dawson_Creek America/Denver America/Detroit America/Dominica America/Edmonton America/Eirunepe America/El_Salvador America/Fort_Nelson America/Fortaleza America/Glace_Bay America/Godthab America/Goose_Bay America/Grand_Turk America/Grenada America/Guadeloupe America/Guatemala America/Guayaquil America/Guyana America/Halifax America/Havana America/Hermosillo America/Indiana/Indianapolis America/Indiana/Knox America/Indiana/Marengo America/Indiana/Petersburg America/Indiana/Tell_City America/Indiana/Vevay America/Indiana/Vincennes America/Indiana/Winamac America/Inuvik America/Iqaluit America/Jamaica America/Juneau America/Kentucky/Louisville America/Kentucky/Monticello America/Kralendijk America/La_Paz America/Lima America/Los_Angeles America/Lower_Princes America/Maceio America/Managua America/Manaus America/Marigot America/Martinique America/Matamoros America/Mazatlan America/Menominee America/Merida America/Metlakatla America/Mexico_City America/Miquelon America/Moncton America/Monterrey America/Montevideo America/Montreal America/Montserrat America/Nassau America/New_York America/Nipigon America/Nome America/Noronha America/North_Dakota/Beulah America/North_Dakota/Center America/North_Dakota/New_Salem America/Ojinaga America/Panama America/Pangnirtung America/Paramaribo America/Phoenix America/Port_of_Spain America/Port-au-Prince America/Porto_Velho America/Puerto_Rico America/Rainy_River America/Rankin_Inlet America/Recife America/Regina America/Resolute America/Rio_Branco America/Santarem America/Santiago America/Santo_Domingo America/Sao_Paulo America/Scoresbysund America/Sitka America/St_Barthelemy America/St_Johns America/St_Kitts America/St_Lucia America/St_Thomas America/St_Vincent America/Swift_Current America/Tegucigalpa America/Thule America/Thunder_Bay America/Tijuana America/Toronto America/Tortola America/Vancouver America/Whitehorse America/Winnipeg America/Yakutat America/Yellowknife Antarctica/Macquarie Arctic/Longyearbyen Asia/Aden Asia/Almaty Asia/Amman Asia/Anadyr Asia/Aqtau Asia/Aqtobe Asia/Ashgabat Asia/Atyrau Asia/Baghdad Asia/Bahrain Asia/Baku Asia/Bangkok Asia/Barnaul Asia/Beirut Asia/Bishkek Asia/Brunei Asia/Chita Asia/Choibalsan Asia/Chongqing Asia/Colombo Asia/Damascus Asia/Dhaka Asia/Dili Asia/Dubai Asia/Dushanbe Asia/Famagusta Asia/Gaza Asia/Harbin Asia/Hebron Asia/Ho_Chi_Minh Asia/Hong_Kong Asia/Hovd Asia/Irkutsk Asia/Jakarta Asia/Jayapura Asia/Jerusalem Asia/Kabul Asia/Kamchatka Asia/Karachi Asia/Kashgar Asia/Kathmandu Asia/Khandyga Asia/Kolkata Asia/Krasnoyarsk Asia/Kuala_Lumpur Asia/Kuching Asia/Kuwait Asia/Macau Asia/Magadan Asia/Makassar Asia/Manila Asia/Muscat Asia/Nicosia Asia/Novokuznetsk Asia/Novosibirsk Asia/Omsk Asia/Oral Asia/Phnom_Penh Asia/Pontianak Asia/Pyongyang Asia/Qatar Asia/Qyzylorda Asia/Rangoon Asia/Riyadh Asia/Sakhalin Asia/Samarkand Asia/Seoul Asia/Shanghai Asia/Singapore Asia/Srednekolymsk Asia/Taipei Asia/Tashkent Asia/Tbilisi Asia/Tehran Asia/Thimphu Asia/Tokyo Asia/Tomsk Asia/Ulaanbaatar Asia/Urumqi Asia/Ust-Nera Asia/Vientiane Asia/Vladivostok Asia/Yakutsk Asia/Yekaterinburg Asia/Yerevan Atlantic/Azores Atlantic/Bermuda Atlantic/Canary Atlantic/Cape_Verde Atlantic/Faroe Atlantic/Madeira Atlantic/Reykjavik Atlantic/South_Georgia Atlantic/St_Helena Atlantic/Stanley Australia/Adelaide Australia/Brisbane Australia/Broken_Hill Australia/Currie Australia/Darwin Australia/Eucla Australia/Hobart Australia/Lindeman Australia/Lord_Howe Australia/Melbourne Australia/Perth Australia/Sydney Europe/Amsterdam Europe/Andorra Europe/Astrakhan Europe/Athens Europe/Belgrade Europe/Berlin Europe/Bratislava Europe/Brussels Europe/Bucharest Europe/Budapest Europe/Busingen Europe/Chisinau Europe/Copenhagen Europe/Dublin Europe/Gibraltar Europe/Guernsey Europe/Helsinki Europe/Isle_of_Man Europe/Istanbul Europe/Jersey Europe/Kaliningrad Europe/Kiev Europe/Kirov Europe/Lisbon Europe/Ljubljana Europe/London Europe/Luxembourg Europe/Madrid Europe/Malta Europe/Mariehamn Europe/Minsk Europe/Monaco Europe/Moscow Europe/Oslo Europe/Paris Europe/Podgorica Europe/Prague Europe/Riga Europe/Rome Europe/Samara Europe/San_Marino Europe/Sarajevo Europe/Saratov Europe/Simferopol Europe/Skopje Europe/Sofia Europe/Stockholm Europe/Tallinn Europe/Tirane Europe/Ulyanovsk Europe/Uzhgorod Europe/Vaduz Europe/Vatican Europe/Vienna Europe/Vilnius Europe/Volgograd Europe/Warsaw Europe/Zagreb Europe/Zaporozhye Europe/Zurich Indian/Antananarivo Indian/Chagos Indian/Christmas Indian/Cocos Indian/Comoro Indian/Kerguelen Indian/Mahe Indian/Maldives Indian/Mauritius Indian/Mayotte Indian/Reunion Pacific/Apia Pacific/Auckland Pacific/Bougainville Pacific/Chatham Pacific/Chuuk Pacific/Easter Pacific/Efate Pacific/Enderbury Pacific/Fakaofo Pacific/Fiji Pacific/Funafuti Pacific/Galapagos Pacific/Gambier Pacific/Guadalcanal Pacific/Guam Pacific/Honolulu Pacific/Johnston Pacific/Kiritimati Pacific/Kosrae Pacific/Kwajalein Pacific/Majuro Pacific/Marquesas Pacific/Midway Pacific/Nauru Pacific/Niue Pacific/Norfolk Pacific/Noumea Pacific/Pago_Pago Pacific/Palau Pacific/Pitcairn Pacific/Pohnpei Pacific/Port_Moresby Pacific/Rarotonga Pacific/Saipan Pacific/Tahiti Pacific/Tarawa Pacific/Tongatapu Pacific/Wake Pacific/Wallis Pacific/Yap
Parameters
| Параметр | Описание |
|---|---|
ianaZone | The name of IANA region. |
mode | Time zone working mode. |
Example
instance.SetIanaTimezone("America/Los_Angeles");MinimizeMemory
Method
Performs a forced garbage collection. May cause the application hangs. ATTENTION! When using MinimizeMemory deletes all references to elements and documents, and thus need to re-obtain elements and documents.
Example
instance.ActiveTab.Navigate("yandex.ru");
instance.ActiveTab.WaitDownloading();
// get html element and set value
var he = instance.ActiveTab.FindElementById("text");
he.SetValue("123", "Full", false);
project.SendInfoToLog(he.ErrorDetected.ToString(), ""); // result "False"
// minimize memory and release references
instance.MinimizeMemory();
// try set value by old reference, but nothing change, because reference was released
he.SetValue("345", "Full", false);
project.SendInfoToLog(he.ErrorDetected.ToString(), ""); // result "True"
// get html element again and successfully set new value
he = instance.ActiveTab.FindElementById("text");
he.SetValue("345", "Full", false);
project.SendInfoToLog(he.ErrorDetected.ToString(), ""); // result "False"GetWebRTCAdresses
Method
Gets the IP addresses, that have been set last time. The returned values will be empty for disable work mode, “default” for enable work mode. For emulate work mode returns user values or empty strings, if user don’t set any values.
Parameters
| Параметр | Описание |
|---|---|
ipv4Address | The “internal” IPv4 address in format “ip:port” for WebRTC. |
ipv6Address | The IPv6 address for WebRTC in format “ip” or “[ip]:port”. |
ipv4Nat | The “external” IPv4 address in format “ip:port” for NAT. |
SetWebRTCAdresses
Method
Sets the IP addresses for emulate WebRTC settings. The method needs isolated process, because it is applied to all instances in the process. It will generate host candidates for RTP on UDP and route through NAT, if it required.
Parameters
| Параметр | Описание |
|---|---|
ipv4Address | The “internal” IPv4 address in format “ip:port” for WebRTC. |
ipv6Address | The IPv6 address for WebRTC. It is optional parameter. Avaliable formats are “ip” or “[ip]:port”. If address hasn’t port, then port generates according to ipv4 port. |
ipv4Nat | The “external” IPv4 address in format “ip:port” for NAT. It is optional parameter. |
mode | WebRTC working mode. |
Example
string ipv4, ipv6, ipNat;
// disable WebRTC
instance.WebRTCWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.WebRTCMode.Disable;
// then WebRTC is disabled, the output variables will be empty
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (!string.IsNullOrWhiteSpace(ipv4) || !string.IsNullOrWhiteSpace(ipv6) || !string.IsNullOrWhiteSpace(ipNat))
throw new Exception("Adresses should be empty then webRTC disabled!!!");
// enable WebRTC
instance.WebRTCWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.WebRTCMode.Enable;
// then WebRTC is enabled, the output variables will be "default"
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (!ipv4.Equals("default") || !ipv6.Equals("default") || !ipNat.Equals("default"))
throw new Exception("Adresses should be 'default' then webRTC enabled!!!");
// emulate WebRTC
instance.WebRTCWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.WebRTCMode.Emulate;
// now the output variables will be empty, because we didn't set any values
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (!string.IsNullOrWhiteSpace(ipv4) || !string.IsNullOrWhiteSpace(ipv6) || !string.IsNullOrWhiteSpace(ipNat))
throw new Exception("Adresses should be empty then webRTC emulate, but not configured!!!");
// format for IPv4 is "ip:port"
// for IPv6 are "ip" or "[ip]:port"
var ipv4Emulate = "192.168.5.5:5687";
var ipv6Emulate = "[2001:0:53aa:62c:24cb:218c:9257:63c]:33282";
var ipNatEmulate = "54.234.21.12:7654";
// you can emulate only local ipv4
instance.SetWebRTCAdresses(ipv4Emulate);
// now the output variable ipv4 will be "192.168.5.5:5687", other variables will be empty
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (ipv4 != ipv4Emulate || !string.IsNullOrWhiteSpace(ipv6) || !string.IsNullOrWhiteSpace(ipNat))
throw new Exception("Wrong set adresses, set only ipv4!!!");
// or you can emulate only local ipv4 and ipv6
instance.SetWebRTCAdresses(ipv4Emulate, ipv6Emulate);
// now the output variable ipv4 will be "192.168.5.5:5687", ipv6 will be "[2001:0:53aa:62c:24cb:218c:9257:63c]:33282", but ipNat will be empty
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (ipv4 != ipv4Emulate || ipv6 != ipv6Emulate || !string.IsNullOrWhiteSpace(ipNat))
throw new Exception("Wrong set adresses, set ipv4 and ipv6!!!");
// or you can emulate all addresses
instance.SetWebRTCAdresses(ipv4Emulate, ipv6Emulate, ipNatEmulate);
// now the output variable ipv4 will be "192.168.5.5:5687", ipv6 will be "[2001:0:53aa:62c:24cb:218c:9257:63c]:33282", ipNat will be "54.234.21.12:7654"
instance.GetWebRTCAdresses(out ipv4, out ipv6, out ipNat);
if (ipv4 != ipv4Emulate || ipv6 != ipv6Emulate || ipNat != ipNatEmulate)
throw new Exception("Wrong set adresses, set ipv4, ipv6, ipNat!!!");GetWebRTCDevices
Method
Returns a collection of current visible devices.
Returns: Collection of plugins.
Example
// get devices
var devices = instance.GetWebRTCDevices();
// name of first device
string name = "";
if (devices != null)
{
var devicesList = devices.ToList();
if(devicesList.Count > 0)
{
name = devicesList[0].Name;
}
}ShowWebRTCDevice
Method
Show the webrtc device. Device emulation works only if WebRTCWorkMode sets to Emulate.
Parameters
| Параметр | Описание |
|---|---|
device | WebRtcDevice object for showing. If it not exist in devices collection, it will be added to colllection. |
Example
// create device item
var device = new ZennoLab.CommandCenter.WebRtcDeviceItem("WebRtcDevice name", "{0.0.0.00000000}" + Guid.NewGuid().ToString("B"), ZennoLab.InterfacesLibrary.Enums.Browser.WebRtcDeviceKind.Video);
// add and show device
instance.ShowWebRTCDevice(device);HideWebRTCDevice
Method
Hide the webrtc device. Device emulation works only if WebRTCWorkMode sets to Emulate.
Parameters
| Параметр | Описание |
|---|---|
device | WebRtcDevice object for hiding. |
Example
// get devices
var devices = instance.GetWebRTCDevices();
// hide first device
if (devices != null)
{
var devicesList = devices.ToList();
if(devicesList.Count > 0)
{
instance.HideWebRTCDevice(devicesList[0]);
}
}LoadWebRTCDevices
Method
Loads devices.
Parameters
| Параметр | Описание |
|---|---|
path | The path to devices. |
Example
// load devices
instance.LoadWebRTCDevices("path");Example2
// load devices
$instance->LoadWebRTCDevices("path");LoadWebRTCDevices
Method
Loads devices.
Parameters
| Параметр | Описание |
|---|---|
devices | The devices data. |
SaveWebRTCDevices
Method
Saves devices.
Parameters
| Параметр | Описание |
|---|---|
path | The path to devices. |
Example
// save devices
instance.SaveWebRTCDevices("path");Example2
// save devices
$instance->SaveWebRTCDevices("path");SaveWebRTCDevices
Method
Saves devices.
Returns: The path to devices.
SetBrowserPreference
Method
Sets the broswer preference. The method needs isolated process, because it is applied to all instances in the process.
Parameters
| Параметр | Описание |
|---|---|
name | The name of preference. |
value | The value of preference. |
Returns: True if the preference successfully setted, otherwise false.
Example
instance.SetBrowserPreference("network.http.speculative-parallel-limit", 0);
instance.SetBrowserPreference("browser.send_pings", false);
instance.SetBrowserPreference("intl.accept_languages", "ru-RU, ru, en-US, en");GetBrowserPreference
Method
Returns the preference of browser.
Parameters
| Параметр | Описание |
|---|---|
name | The name of preference. |
Returns: The value of browser preference. May has type string, int or boolean
ChangeRequest
Method
Replaces data of browser request.
To find the request use regex “regexUrl”. To replace data in the request body use collections “regexesForReplace” and “datasForReplace”, the first collection contains regular expressions that will replace the original data with the corresponding elements from the second collection. The “regexesForReplace” and “datasForReplace” collections should has a same size, otherwise the method doesn’t perform and set ErrorDetected to True.
Parameters
| Параметр | Описание |
|---|---|
regexUrl | The regex string to find the request url. |
regexesForReplace | Collection of regexs to find data in the request body. |
datasForReplace | Collection of strings to replace the relevant data. |
allTime | The true if use this replacement all time; otherwise and default, false. |
Example
instance.ChangeResponse("http://lessons.zennolab.com/en/index",
new List<string>
{
"(?<=<input type=\"checkbox\" class=\"inputs\"><h2> ).*(?=</h2>)",
"(?<=<textarea rows=\"5\" cols=\"45\" name=\"text\">).*(?=</textarea>)",
"<h2>Any text:</h2>"
},
new List<string>
{
"no OS",
"NEW TEXT TO TEXTAREA",
"<h2>NEW HEADER TO TEXTAREA:</h2>"
});
instance.ChangeRequest(@"(?<=https://mc\.yandex\.ru/webvisor/).*", new List<string> { @"(?<=wv-data=).*" }, new List<string> { "NODATA" }, true);
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();ChangeResponse
Method
Replaces data of browser response.
To find the response use regex “regexUrl”. To replace data in the response body use collections “regexesForReplace” and “datasForReplace”, the first collection contains regular expressions that will replace the original data with the corresponding elements from the second collection. The “regexesForReplace” and “datasForReplace” collections should has a same size, otherwise the method doesn’t perform and set ErrorDetected to True.
Parameters
| Параметр | Описание |
|---|---|
regexUrl | The regex string to find the response url. |
regexesForReplace | Collection of regexs to find data in the response body. |
datasForReplace | Collection of strings to replace the relevant data. |
allTime | The true if use this replacement all time; otherwise and default, false. |
Example
instance.ChangeResponse("http://lessons.zennolab.com/en/index",
new List<string>
{
"(?<=<input type=\"checkbox\" class=\"inputs\"><h2> ).*(?=</h2>)",
"(?<=<textarea rows=\"5\" cols=\"45\" name=\"text\">).*(?=</textarea>)",
"<h2>Any text:</h2>"
},
new List<string>
{
"no OS",
"NEW TEXT TO TEXTAREA",
"<h2>NEW HEADER TO TEXTAREA:</h2>"
});
instance.ChangeRequest(@"(?<=https://mc\.yandex\.ru/webvisor/).*", new List<string> { @"(?<=wv-data=).*" }, new List<string> { "NODATA" }, true);
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();SaveSuperCookie
Method
Saves super cookie.
Parameters
| Параметр | Описание |
|---|---|
path | The path to cookie. |
Example
// save cookie
instance.SaveSuperCookie("path");Example2
// save cookie
$instance->SaveSuperCookie("path");SaveSuperCookie
Method
Saves super cookie.
Returns: The super cookies data.
Example
// get byte array of super cookie
byte[] cookieBytes = instance.SaveSuperCookie();
// convert byte array to string and return result
return System.Text.Encoding.UTF8.GetString(cookieBytes);Example2
// get byte array of super cookie
cookieBytes = instance.SaveSuperCookie();
// convert byte array to string and return result
return System.Text.Encoding.UTF8.GetString(cookieBytes);LoadSuperCookie
Method
Loads super cookie.
Parameters
| Параметр | Описание |
|---|---|
path | The path to super cookie. |
Example
// load super cookie
instance.LoadSuperCookie("path");Example2
// load super cookie
$instance->LoadSuperCookie("path");LoadSuperCookie
Method
Loads super cookie.
Parameters
| Параметр | Описание |
|---|---|
cookie | The super cookies data. |
Example
// format super cookie string
string cookie = @"mc.yandex.ru:HSTS 0 17324 1528380625408,1,0
yastatic.net:HSTS 0 17324 1540044588554,1,1";
// convert super cookie string to byte array
byte[] cookieBytes = System.Text.Encoding.UTF8.GetBytes(cookie);
// load cookie
instance.LoadSuperCookie(cookieBytes);Example2
// format super cookie string
$cookie = @"mc.yandex.ru:HSTS 0 17324 1528380625408,1,0
yastatic.net:HSTS 0 17324 1540044588554,1,1";
// convert super cookie string to byte array
$cookieBytes = System\Text\Encoding\UTF8::GetBytes($cookie);
// load cookie
$instance->LoadSuperCookie($cookieBytes);SetSuperCookie
Method
Sets super cookie.
Parameters
| Параметр | Описание |
|---|---|
cookie | The super cookies data in format “Key\tScore\tLastAccessed\tValue”. |
Example
// format super cookie string
string cookie = @"mc.yandex.ru:HSTS 0 17324 1528380625408,1,0
yastatic.net:HSTS 0 17324 1540044588554,1,1";
// load cookie
instance.SetSuperCookie(cookie);Example2
// format super cookie string
$cookie = @"mc.yandex.ru:HSTS 0 17324 1528380625408,1,0
yastatic.net:HSTS 0 17324 1540044588554,1,1";
// load cookie
$instance->SetSuperCookie($cookie);GetSuperCookie
Method
Gets super cookie.
Parameters
| Параметр | Описание |
|---|---|
domain | The domain of cookie. The default value is empty string. |
Returns: The ыгзук cookies in the string format.
Example
instance.ActiveTab.Navigate("http://google.com/");
instance.ActiveTab.WaitDownloading();
// get super cookie by domain
return instance.GetSuperCookie("google.com");Example2
$instance->ActiveTab->Navigate("http://google.com/");
$instance->ActiveTab->WaitDownloading();
// get super cookie by domain
return $instance->GetSuperCookie("google.com");GetFonts
Method
Returns a collection of current visible fonts.
Returns: Collection of fonts.
Example
// get fonts
var fonts = instance.GetFonts();
// name of first font
string name = "";
if (fonts != null)
{
var fontList = fonts.ToList();
if(fontList.Count > 0)
{
name = fontList[0];
}
}ShowFont
Method
Show the font. The method needs isolated process, because it is applied to all instances in the process. If browser is Chrome, fonts changes applies only for new tabs.
Parameters
| Параметр | Описание |
|---|---|
font | Font name string for showing. If it not exist in default fonts collection or in FontsFolder, it will be ignored. |
Example
// show font
instance.ShowFont("Arial");HideFont
Method
Hide the font. The method needs isolated process, because it is applied to all instances in the process. If browser is Chrome, fonts changes applies only for new tabs.
Parameters
| Параметр | Описание |
|---|---|
font | Font name string for hiding. |
Example
// hide font
instance.HideFont("Arial");LoadFonts
Method
Loads fonts. The method needs isolated process, because it is applied to all instances in the process. If browser is Chrome, fonts changes applies only for new tabs.
Parameters
| Параметр | Описание |
|---|---|
path | The path to fonts. |
Example
// load fonts
instance.LoadFonts("path");Example2
// load fonts
$instance->LoadFonts("path");LoadFonts
Method
Loads fonts. The method needs isolated process, because it is applied to all instances in the process. If browser is Chrome, fonts changes applies only for new tabs.
Parameters
| Параметр | Описание |
|---|---|
fonts | The fonts data. |
SaveFonts
Method
Saves fonts. The method needs isolated process, because it is applied to all instances in the process.
Parameters
| Параметр | Описание |
|---|---|
path | The path to fonts. |
Example
// save fonts
instance.SaveFonts("path");Example2
// save fonts
$instance->SaveFonts("path");SaveFonts
Method
Saves fonts. The method needs isolated process, because it is applied to all instances in the process.
Returns: The fonts data.
FlushDataOnDisk
Method
Saves folder with browser profile
LoadIndexedDb
Method
Loads indexedDB.
Parameters
| Параметр | Описание |
|---|---|
path | The path to indexedDB file. |
Example
// load IndexedDb
instance.LoadIndexedDb("path");Example2
// load IndexedDb
$instance->LoadIndexedDb("path");LoadIndexedDb
Method
Loads indexedDB.
Parameters
| Параметр | Описание |
|---|---|
databases | The indexedDB data. |
SaveIndexedDb
Method
Saves indexedDB.
Parameters
| Параметр | Описание |
|---|---|
path | The path to fonts. |
Example
// save IndexedDb
instance.SaveIndexedDb("path");Example2
// save IndexedDb
$instance->SaveIndexedDb("path");SaveIndexedDb
Method
Saves indexedDB.
Returns: The indexedDB data.
WaitForPreparing
Method
Wait while instance prerpare all tabs.
StopDownloads
Method
Stop the active downloads.
op_Equality
Method
Parameters
| Параметр | Описание |
|---|---|
x | |
y |
op_Inequality
Method
Parameters
| Параметр | Описание |
|---|---|
x | |
y |
Equals
Method
Determines whether the specified Instance object is equal to the current Instance object.
Parameters
| Параметр | Описание |
|---|---|
other | The Instance object to compare with the current Instance object. |
Returns: The true if the specified Instance object is equal to the current Instance object; otherwise, false.
Equals
Method
Determines whether the specified object is equal to the current Instance object.
Parameters
| Параметр | Описание |
|---|---|
obj | The object to compare with the current object. |
Returns: The true if the specified object is equal to the current Instance object; otherwise, false.
GetHashCode
Method
Returns the hash code for this Instance object.
Returns: A 32-bit signed integer hash code.
WaitFieldEmulationDelay
Method
Waits for end of the filling up field.
Example
// clear cookie
instance.ClearCookie();
// navigate to lessons.zennolab.com
instance.ActiveTab.Navigate("lessons.zennolab.com", "");
// wait for downloading
instance.ActiveTab.WaitDownloading();
// find html element
HtmlElement he = instance.ActiveTab.AllDocuments.Documents[0].FindElementByTag("textarea", 0);
// if html element not exist
if (he.IsNull && he.IsVoid) return -1;
// set input field emulation delay
instance.FieldEmulationDelay = 20000;
// restarting input delay timer for the first call WaitFieldEmulationDelay
instance.RefreshFieldEmulationDelay();
// set value
he.SetValue("It's just not a larger text for testing this method. And for showing how to use C# or PHP code for making the nice projects.", "Full", false);
// and wait if delay time has not passed
instance.WaitFieldEmulationDelay();
// but now shows message that all done
System.Windows.Forms.MessageBox.Show("All done", "End of action");Example2
// clear cookie
$instance->ClearCookie();
// navigate to lessons.zennolab.com
$instance->ActiveTab->Navigate("lessons.zennolab.com", "");
// wait for downloading
$instance->ActiveTab->WaitDownloading();
// find html element
$he = $instance->ActiveTab->AllDocuments->Documents[0]->FindElementByTag("textarea", 0);
// if html element exist
if (!$he->IsNull && !$he->IsVoid)
{
// set value
$he->SetValue("It's just not a larger text for testing this method. And for showing how to use C# or PHP code for making the nice projects.", "Full", false);
// and wait
$instance->WaitFieldEmulationDelay();
}
// but now show message that all done
System\Windows\Forms\MessageBox::Show("All done", "End of action");RefreshFieldEmulationDelay
Method
Refresh the field emulation delay.
Example
// clear cookie
instance.ClearCookie();
// navigate to lessons.zennolab.com
instance.ActiveTab.Navigate("lessons.zennolab.com", "");
// wait for downloading
instance.ActiveTab.WaitDownloading();
// find html element
HtmlElement he = instance.ActiveTab.AllDocuments.Documents[0].FindElementByTag("textarea", 0);
// if html element not exist
if (he.IsNull && he.IsVoid) return -1;
// set input field emulation delay
instance.FieldEmulationDelay = 20000;
// restarting input delay timer for the first call WaitFieldEmulationDelay
instance.RefreshFieldEmulationDelay();
// set value
he.SetValue("It's just not a larger text for testing this method. And for showing how to use C# or PHP code for making the nice projects.", "Full", false);
// and wait if delay time has not passed
instance.WaitFieldEmulationDelay();
// but now shows message that all done
System.Windows.Forms.MessageBox.Show("All done", "End of action");InvokeOnMessageLog
Method
Parameters
| Параметр | Описание |
|---|---|
e |
InvokeOnReload
Method
InvokeOnCheckProxy
Method
InvokeOnSetProxy
Method
InvokeOnToProfile
Method
Parameters
| Параметр | Описание |
|---|---|
e |
Test
Method
Тест
GetNull
Method
Возвращает пустой инстанс