Instance
Assembly: ZennoLab.CommandCenter
Full name: ZennoLab.CommandCenter.Instance
Kind: class
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(int port)
Constructor
Initialize a new instance of the Instance class with deafult url and address
Parameters
| Type | Name | Description |
|---|---|---|
int | 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(string url, int port, string address)
Constructor
Initialize a new instance of the Instance class
Parameters
| Type | Name | Description |
|---|---|---|
string | url | A string expression that evaluates to the URL. |
int | port | The port of the instance. |
string | 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(int port, ConnectionType connectionType)
Constructor
Initialize a new instance of the Instance class with deafult url and address
Parameters
| Type | Name | Description |
|---|---|---|
int | port | The port of the instance. |
ConnectionType | 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(string url, int port, string address, ConnectionType connectionType)
Constructor
Initialize a new instance of the Instance class
Parameters
| Type | Name | Description |
|---|---|---|
string | url | A string expression that evaluates to the URL. |
int | port | The port of the instance. |
string | address | This parameter can take the following values: “debug” and “server”. The default value is “server”. |
ConnectionType | 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
CommandTransfer Transfer { get; set; }
Port
Property
int Port { get; set; }
Gets or sets the current port of the Instance object.
Url
Property
string Url { get; set; }
Gets the host of the pipe.
Address
Property
string Address { get; set; }
Get instances mode.
IsVoid
Property
bool IsVoid { get; }
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
string ZP_ID { get; }
Gets the ID which represents document on the server.
It is used only for the technical purposes
ErrorDetected
Property
bool ErrorDetected { get; }
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
Tab[] AllTabs { get; }
Gets the all open tabs.
Example
// get all tabs
Tab[] tabs = instance.AllTabs;Example2
// get all tabs
$tabs = $instance->AllTabs;MainTab
Property
Tab MainTab { get; }
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
Tab ActiveTab { get; }
Gets the active tab.
Example
// get active tab
Tab activeTab = instance.ActiveTab;Example2
// get active tab
$activeTab = $instance->ActiveTab;ActiveExtension
Property
Tab ActiveExtension { get; }
Gets the active extension.
Example
// get active extension
Tab activeExtension = instance.ActiveExtension;Example2
// get active extension
activeExtension = $instance->ActiveExtension;IsExtensionWorking
Property
bool IsExtensionWorking { get; }
Gets a value that indicates whether extension activated (working).
LoadPictures
Property
bool LoadPictures { get; set; }
Gets or sets a value that indicates whether loading picture from server are allowed.
FormTitle
Property
string FormTitle { get; }
Gets the parent form title
AllowPopUp
Property
bool AllowPopUp { get; set; }
Gets or sets a value that indicates whether popups are allowed.
AllowScriptError
Property
bool AllowScriptError { get; set; }
Gets or sets a value that indicates whether script error are allowed.
BackGroundSoundsPlay
Property
bool BackGroundSoundsPlay { get; set; }
Gets or sets a value that indicates whether play background sounds associated with the document are allowed.
DownloadActiveX
Property
bool DownloadActiveX { get; set; }
Gets or sets a value that indicates whether to download ActiveX controls are allowed.
DownloadFrame
Property
bool DownloadFrame { get; set; }
Gets or sets a value that indicates whether download contents of frames are allowed.
UseJavaApplets
Property
bool UseJavaApplets { get; set; }
Gets or sets a value that indicates whether to run Java applets are allowed.
UsePlugins
Property
bool UsePlugins { get; set; }
Gets or sets a value that indicates whether to run Plugins are allowed.
UseMedia
Property
bool UseMedia { get; set; }
Gets or sets a value that indicates whether to use media content are allowed.
RunActiveX
Property
bool RunActiveX { get; set; }
Gets or sets a value that indicates whether to run on the execution of ActiveX controls are allowed.
UseJavaScripts
Property
bool UseJavaScripts { get; set; }
Gets or sets a value that indicates whether use of Java scripts are allowed.
UseCSS
Property
bool UseCSS { get; set; }
Gets or sets a value that indicates whether use of CSS are allowed.
UseAdds
Property
bool UseAdds { get; set; }
Gets or sets a value that indicates whether blocks adds.
UsePluginsForceWmode
Property
bool UsePluginsForceWmode { get; set; }
Gets or sets a value that indicates whether use of Java scripts are allowed.
ForceTouch
Property
bool ForceTouch { get; set; }
Gets or sets a value that indicates whether user’s manual mouse input must be replaced with touch events.
UseBrowserWithoutContent
Property
bool UseBrowserWithoutContent { get; set; }
Gets or sets a value that indicates whether show content of the browser.
DownloadVideos
Property
bool DownloadVideos { get; set; }
Gets or sets a value that indicates whether download videos contained in the document are allowed.
DownloadsPath
Property
string DownloadsPath { get; set; }
Gets or sets the path for downloads.
EmulationLevel
Property
string EmulationLevel { get; set; }
Gets or sets the current emulation level.
ScreenResolution
Property
Size ScreenResolution { get; }
Gets the screen resolution.
IgnoreAjaxRequests
Property
bool IgnoreAjaxRequests { get; set; }
Gets or set the information about ignoring ajax requests.
IgnoreFlashRequests
Property
bool IgnoreFlashRequests { get; set; }
Gets or set the information about ignoring flash requests.
IgnoreAdditionalRequests
Property
bool IgnoreAdditionalRequests { get; set; }
Gets or set the information about ignoring additional requests.
IgnoreFrameRequests
Property
bool IgnoreFrameRequests { get; set; }
Gets or set the information about ignoring frame requests.
SymbolEmulationDelay
Property
int SymbolEmulationDelay { get; set; }
Gets or sets the symbol emulation delay.
FieldEmulationDelay
Property
int FieldEmulationDelay { get; set; }
Gets or sets the field emulation delay.
ScreenOrientation
Property
ScreenOrientation ScreenOrientation { get; set; }
Gets or set the screen orientation.
AudioPreferences
Property
AudioPreferences AudioPreferences { get; set; }
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
WebGLPreferences WebGLPreferences { get; set; }
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
bool UrlManipulation { get; set; }
Gets or set the information about url manipulation.
LastDownloadedFile
Property
string LastDownloadedFile { get; }
Gets the path of the last downloaded file.
UseGeoposition
Property
bool UseGeoposition { get; set; }
Gets or sets a value that indicates whether to use geoposition are allowed.
CanvasRenderMode
Property
CanvasMode CanvasRenderMode { get; set; }
Gets or set the information about canvas render mode.
Example
instance.CanvasRenderMode = ZennoLab.InterfacesLibrary.Enums.Browser.CanvasMode.Emulate;
instance.CanvasRenderSeed = "5caf24ded0e11f4a29a3ba236152c4d1";CanvasMissMode
Property
CanvasMissModeEnum CanvasMissMode { get; set; }
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
string CanvasRenderSeed { get; set; }
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
TimezoneMode TimezoneWorkMode { get; set; }
Gets or set the information about time zone working mode.
Example
instance.TimezoneWorkMode = ZennoLab.InterfacesLibrary.Enums.Browser.TimezoneMode.Emulate;AudioContextMode
Property
AudioMode AudioContextMode { get; set; }
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
string AudioContextSeed { get; set; }
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
ClientRectMode ClientRectWorkMode { get; set; }
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
string ClientRectSeed { get; set; }
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
WebRTCMode WebRTCWorkMode { get; set; }
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");HCaptchaCaptureEnabled
Property
bool HCaptchaCaptureEnabled { get; set; }
UseTrafficMonitoring
Property
bool UseTrafficMonitoring { get; set; }
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
string FontsFolder { get; set; }
Gets or sets path of additional fonts folder. The fonts from the folder may be used for ShowFont/HideFont methods.
ProfilePath
Property
string ProfilePath { get; }
Gets path of profile for instance.
CachePath
Property
string CachePath { get; }
Gets path of cache for instance.
UsesFolderProfile
Property
bool UsesFolderProfile { get; }
Gets whether instance uses folder profile on disk or not.
BrowserType
Property
BrowserType BrowserType { get; }
Gets the type of browser.
UseToStringEmulation
Property
bool UseToStringEmulation { get; set; }
Gets or sets a value that indicates whether use javascript toString() emulation.
UseJsFeatures
Property
bool UseJsFeatures { get; set; }
Gets or sets a value that indicates whether use javascript features.
UseFullMouseEmulation
Property
bool UseFullMouseEmulation { get; set; }
Gets or sets a value that indicates whether use full mouse emulation features where it posible.
AllowNotification
Property
bool AllowNotification { get; set; }
Gets or sets a value that indicates whether allow browser notification.
LastNotificationTitle
Property
string LastNotificationTitle { get; }
Gets the last notification title of the browser.
ClearTrafficWhenNavigate
Property
bool ClearTrafficWhenNavigate { get; set; }
Gets or sets whether the traffic items are to be cleared when navigating.
LastNotificationText
Property
string LastNotificationText { get; }
Gets the last notification text of the browser.
AutoRetry
Property
bool AutoRetry { get; set; }
Gets or sets a value that indicates whether retry requests. Works only in Chrome.
AutoRetryMaxAttempts
Property
int AutoRetryMaxAttempts { get; set; }
Gets or set retry requests attempts. Works only in Chrome.
AutoRetry5xxResponses
Property
bool AutoRetry5xxResponses { get; set; }
Gets or sets a value that indicates whether retry requests with response code 5xx. Works only in Chrome.
FrameRate
Property
int FrameRate { get; set; }
Gets or set frame rate of the browser. Works only in Chrome.
AnimationFrameRate
Property
int AnimationFrameRate { get; set; }
Gets or set animation frame rate of the browser. Works only in Chrome.
NavigatorPermissions
Property
string NavigatorPermissions { get; set; }
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
string SpeechSynthesisVoices { get; set; }
Sets or gets a JSON document, which is a config for voices in the Speech Synthesis API
DevicePixelRatio
Property
double DevicePixelRatio { get; set; }
Get or set device pixel ratio of the browser. Works only in Chrome.
WsConnectionString
Property
string WsConnectionString { get; }
Gets the websocket connection string for Chromium browser.
NavigateErrorCountRunning
Property
int NavigateErrorCountRunning { get; set; }
Gets or sets the count of the detected navigation errors.
Methods
Equals
Method
bool Equals(Instance other)
Determines whether the specified Instance object is equal to the current Instance object.
Parameters
| Type | Name | Description |
|---|---|---|
Instance | 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
bool Equals(object obj)
Determines whether the specified object is equal to the current Instance object.
Parameters
| Type | Name | Description |
|---|---|---|
object | 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
int GetHashCode()
Returns the hash code for this Instance object.
Returns: A 32-bit signed integer hash code.
WaitFieldEmulationDelay
Method
void WaitFieldEmulationDelay()
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");PrepareInstance
Method
void PrepareInstance(string flags, string emulationLevel, bool needHandleAdditional, bool browserWithoutContext, bool forceClearCache, bool needEventSetDefaultPreference, string id, bool preventClearingAnything)
Parameters
| Type | Name | Description |
|---|---|---|
string | flags | |
string | emulationLevel | |
bool | needHandleAdditional | |
bool | browserWithoutContext | |
bool | forceClearCache | |
bool | needEventSetDefaultPreference | |
string | id | |
bool | preventClearingAnything |
RefreshFieldEmulationDelay
Method
void RefreshFieldEmulationDelay()
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");Dispose
Method
void Dispose()
GetExtensionByName
Method
IExtension GetExtensionByName(string name)
Parameters
| Type | Name | Description |
|---|---|---|
string | name |
GetExtensionById
Method
IExtension GetExtensionById(string id)
Parameters
| Type | Name | Description |
|---|---|---|
string | id |
GetAllExtensions
Method
IExtension[] GetAllExtensions()
InstallCrxExtension
Method
IExtension InstallCrxExtension(string path)
Parameters
| Type | Name | Description |
|---|---|---|
string | path |
UninstallExtension
Method
bool UninstallExtension(string id)
Parameters
| Type | Name | Description |
|---|---|---|
string | id |
UninstallExtension
Method
bool UninstallExtension(IExtension extension)
Parameters
| Type | Name | Description |
|---|---|---|
IExtension | extension |
SetFilesForUpload
Method
void SetFilesForUpload(string files)
Sets the files for upload.
Parameters
| Type | Name | Description |
|---|---|---|
string | files | The paths of files for upload |
FindElementByIntelliSearch
Method
HtmlElement FindElementByIntelliSearch(string form, string elementClass, bool isLink, bool inBlocked)
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
| Type | Name | Description |
|---|---|---|
string | form | The form for searching. It’s can be name on one of supported languages or id from current IntelliSearch base. |
string | elementClass | The class of element for searching. It’s can be name on one of supported languages or id from current IntelliSearch base. |
bool | 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. |
bool | 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
void SendText(string text, int latency)
Emulates the typing.
Parameters
| Type | Name | Description |
|---|---|---|
string | text | The text for typing. |
int | 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
void Click(int xMin, int xMax, int yMin, int yMax, string clickType, string clickDistributionType)
Emulates a click on specified area.
The emulation of click made only on the active tab.
Parameters
| Type | Name | Description |
|---|---|---|
int | xMin | minimum x coordinate. |
int | xMax | maximum x coordinate. |
int | yMin | minimum y coordinate. |
int | yMax | maximum y coordinate. |
string | clickType | The mouse button type. It can have a value “Left”, “Right”, “DoubleClick”. |
string | 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
void IntelliSearchSetBase(int revision, string path, string password)
Sets base of IntelliSearch.
Parameters
| Type | Name | Description |
|---|---|---|
int | revision | The revision of base. |
string | path | |
string | password | The password |
IntelliSearchSetAdditionalBase
Method
void IntelliSearchSetAdditionalBase(string path)
Sets additional base of IntelliSearch.
Parameters
| Type | Name | Description |
|---|---|---|
string | 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
void SetWindowPreference(string preference, int value)
Sets the window settings.
Parameters
| Type | Name | Description |
|---|---|---|
string | preference | The setting of window. |
int | value | The value of setting. |
SetWindowPreference
Method
void SetWindowPreference(WindowPreference preference, int value)
Sets the window settings.
Parameters
| Type | Name | Description |
|---|---|---|
WindowPreference | preference | The setting of window. |
int | value | The value of setting. |
SetScreenPreference
Method
void SetScreenPreference(string preference, int value)
Sets the screen settings.
Parameters
| Type | Name | Description |
|---|---|---|
string | preference | The setting of screen. |
int | value | The value of setting. |
SetScreenPreference
Method
void SetScreenPreference(ScreenPreference preference, int value)
Sets the screen settings.
Parameters
| Type | Name | Description |
|---|---|---|
ScreenPreference | preference | The setting of screen. |
int | value | The value of setting. |
SetWindowSize
Method
void SetWindowSize(int width, int height)
Sets the size of window.
Parameters
| Type | Name | Description |
|---|---|---|
int | width | The width of window. |
int | height | The height of window. |
WaitForUserAction
Method
void WaitForUserAction(int timeout)
Show instance window and wait for user action.
Parameters
| Type | Name | Description |
|---|---|---|
int | 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
void WaitForUserAction(int timeout, string comment)
Show instance window and wait for user action.
Parameters
| Type | Name | Description |
|---|---|---|
int | timeout | The timeout of waiting in seconds. |
string | 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
void AddToTitle(string value)
Add text to title of instance.
Parameters
| Type | Name | Description |
|---|---|---|
string | value | The text to add. |
GetContentPolicy
Method
string GetContentPolicy()
Returns the content policy mode. It can have a value “DirectLoad”, “WhiteList”, “BlockList”.
Returns: The content policy mode for instance.
GetContentPolicyDomains
Method
IEnumerable<string> GetContentPolicyDomains()
Returns collection of domains texts for “WhiteList” or “BlockList” policy.
Returns: Collection of domains.
GetContentPolicyRegexs
Method
IEnumerable<string> GetContentPolicyRegexs()
Returns collection of regexs for “WhiteList” or “BlockList” policy.
Returns: Collection of regexs.
SetContentPolicy
Method
void SetContentPolicy(string policy, IEnumerable<string> domains, IEnumerable<string> regexs)
Sets the policy for browser content.
Parameters
| Type | Name | Description |
|---|---|---|
string | policy | The type of policy. It can have a value “DirectLoad”, “WhiteList”, “BlockList”. |
IEnumerable<string> | domains | Collection of domains for “WhiteList” or “BlockList” policy. Default value is null. |
IEnumerable<string> | 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
void GetGeoposition(Double& latitude, Double& longitude, Double& accuracy, Double& altitude, Double& altitudeAccuracy, Double& heading, Double& speed)
Parameters
| Type | Name | Description |
|---|---|---|
Double& | latitude | |
Double& | longitude | |
Double& | accuracy | |
Double& | altitude | |
Double& | altitudeAccuracy | |
Double& | heading | |
Double& | speed |
SetGeoposition
Method
void SetGeoposition(double latitude, double longitude, double accuracy, double altitude, double altitudeAccuracy, double heading, double speed)
Sets the geoposition coordinates and enables it for websites.
Parameters
| Type | Name | Description |
|---|---|---|
double | latitude | The position’s latitude in decimal degrees. |
double | longitude | The position’s longitude in decimal degrees. |
double | accuracy | The accuracy of the latitude and longitude, expressed in meters. |
double | altitude | The position’s altitude in metres, relative to sea level. The default value is 0. |
double | altitudeAccuracy | The accuracy of the altitude expressed in meters. The default value is 0. |
double | 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. |
double | speed | The velocity of the device in meters per second. The default value is 0. |
SetCanvasEmulationSettings
Method
void SetCanvasEmulationSettings(CanvasEmulationSettings settings)
Set settings for SuperEmulation canvas render mode.
Parameters
| Type | Name | Description |
|---|---|---|
CanvasEmulationSettings | settings |
Example
instance.CanvasRenderMode = ZennoLab.InterfacesLibrary.Enums.Browser.CanvasMode.SuperEmulation;
instance.CanvasRenderSeed = "5caf24ded0e11f4a29a3ba236152c4d1";
instance.SetCanvasEmulationSettings(new CanvasEmulationSettings() { DropPotentialRandomlyAlgorithms = true });GetTimezone
Method
void GetTimezone(Int32& hours, Int32& minutes)
Parameters
| Type | Name | Description |
|---|---|---|
Int32& | hours | |
Int32& | minutes |
GetIanaTimezone
Method
string GetIanaTimezone()
Gets the system timezone.
Returns: The name of IANA region. If IANA region doesn’t set, will be returned string.Empty
SetTimezone
Method
void SetTimezone(int hours, int minutes, TimezoneMode mode)
Sets the system timezone.
Parameters
| Type | Name | Description |
|---|---|---|
int | hours | The number of hours in the difference between the current time zone and UTC. Possible values from -12 to 12. |
int | 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. |
TimezoneMode | mode | Time zone working mode. |
Example
instance.SetTimezone(-4, 0); // UTC -04:00SetIanaTimezone
Method
void SetIanaTimezone(string ianaZone, TimezoneMode mode)
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
| Type | Name | Description |
|---|---|---|
string | ianaZone | The name of IANA region. |
TimezoneMode | mode | Time zone working mode. |
Example
instance.SetIanaTimezone("America/Los_Angeles");MinimizeMemory
Method
void MinimizeMemory()
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
void GetWebRTCAdresses(String& ipv4Address, String& ipv6Address, String& ipv4Nat)
Parameters
| Type | Name | Description |
|---|---|---|
String& | ipv4Address | |
String& | ipv6Address | |
String& | ipv4Nat |
SetWebRTCAdresses
Method
void SetWebRTCAdresses(string ipv4Address, string ipv6Address, string ipv4Nat, WebRTCMode mode)
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
| Type | Name | Description |
|---|---|---|
string | ipv4Address | The “internal” IPv4 address in format “ip:port” for WebRTC. |
string | 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. |
string | ipv4Nat | The “external” IPv4 address in format “ip:port” for NAT. It is optional parameter. |
WebRTCMode | 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
IEnumerable<WebRtcDeviceItem> GetWebRTCDevices()
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
void ShowWebRTCDevice(WebRtcDeviceItem device)
Show the webrtc device. Device emulation works only if WebRTCWorkMode sets to Emulate.
Parameters
| Type | Name | Description |
|---|---|---|
WebRtcDeviceItem | 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
void HideWebRTCDevice(WebRtcDeviceItem device)
Hide the webrtc device. Device emulation works only if WebRTCWorkMode sets to Emulate.
Parameters
| Type | Name | Description |
|---|---|---|
WebRtcDeviceItem | 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
void LoadWebRTCDevices(string path)
Loads devices.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to devices. |
Example
// load devices
instance.LoadWebRTCDevices("path");Example2
// load devices
$instance->LoadWebRTCDevices("path");LoadWebRTCDevices
Method
void LoadWebRTCDevices(Byte[] devices)
Loads devices.
Parameters
| Type | Name | Description |
|---|---|---|
Byte[] | devices | The devices data. |
SaveWebRTCDevices
Method
void SaveWebRTCDevices(string path)
Saves devices.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to devices. |
Example
// save devices
instance.SaveWebRTCDevices("path");Example2
// save devices
$instance->SaveWebRTCDevices("path");SaveWebRTCDevices
Method
Byte[] SaveWebRTCDevices()
Saves devices.
Returns: The path to devices.
SetBrowserPreference
Method
bool SetBrowserPreference(string name, object value)
Sets the broswer preference. The method needs isolated process, because it is applied to all instances in the process.
Parameters
| Type | Name | Description |
|---|---|---|
string | name | The name of preference. |
object | 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
object GetBrowserPreference(string name)
Returns the preference of browser.
Parameters
| Type | Name | Description |
|---|---|---|
string | name | The name of preference. |
Returns: The value of browser preference. May has type string, int or boolean
ChangeRequest
Method
void ChangeRequest(string regexUrl, IEnumerable<string> regexesForReplace, IEnumerable<string> datasForReplace, bool allTime)
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
| Type | Name | Description |
|---|---|---|
string | regexUrl | The regex string to find the request url. |
IEnumerable<string> | regexesForReplace | Collection of regexs to find data in the request body. |
IEnumerable<string> | datasForReplace | Collection of strings to replace the relevant data. |
bool | 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
void ChangeResponse(string regexUrl, IEnumerable<string> regexesForReplace, IEnumerable<string> datasForReplace, bool allTime)
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
| Type | Name | Description |
|---|---|---|
string | regexUrl | The regex string to find the response url. |
IEnumerable<string> | regexesForReplace | Collection of regexs to find data in the response body. |
IEnumerable<string> | datasForReplace | Collection of strings to replace the relevant data. |
bool | 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
void SaveSuperCookie(string path)
Saves super cookie.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to cookie. |
Example
// save cookie
instance.SaveSuperCookie("path");Example2
// save cookie
$instance->SaveSuperCookie("path");SaveSuperCookie
Method
Byte[] SaveSuperCookie()
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
void LoadSuperCookie(string path)
Loads super cookie.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to super cookie. |
Example
// load super cookie
instance.LoadSuperCookie("path");Example2
// load super cookie
$instance->LoadSuperCookie("path");LoadSuperCookie
Method
void LoadSuperCookie(Byte[] cookie)
Loads super cookie.
Parameters
| Type | Name | Description |
|---|---|---|
Byte[] | 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
void SetSuperCookie(string cookie)
Sets super cookie.
Parameters
| Type | Name | Description |
|---|---|---|
string | 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
string GetSuperCookie(string domain)
Gets super cookie.
Parameters
| Type | Name | Description |
|---|---|---|
string | 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
IEnumerable<string> GetFonts()
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
bool ShowFont(string font)
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
| Type | Name | Description |
|---|---|---|
string | 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
void HideFont(string font)
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
| Type | Name | Description |
|---|---|---|
string | font | Font name string for hiding. |
Example
// hide font
instance.HideFont("Arial");LoadFonts
Method
void LoadFonts(string path)
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
| Type | Name | Description |
|---|---|---|
string | path | The path to fonts. |
Example
// load fonts
instance.LoadFonts("path");Example2
// load fonts
$instance->LoadFonts("path");LoadFonts
Method
void LoadFonts(Byte[] fonts)
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
| Type | Name | Description |
|---|---|---|
Byte[] | fonts | The fonts data. |
SaveFonts
Method
void SaveFonts(string path)
Saves fonts. The method needs isolated process, because it is applied to all instances in the process.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to fonts. |
Example
// save fonts
instance.SaveFonts("path");Example2
// save fonts
$instance->SaveFonts("path");SaveFonts
Method
Byte[] SaveFonts()
Saves fonts. The method needs isolated process, because it is applied to all instances in the process.
Returns: The fonts data.
FlushDataOnDisk
Method
void FlushDataOnDisk()
Saves folder with browser profile
LoadIndexedDb
Method
void LoadIndexedDb(string path)
Loads indexedDB.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to indexedDB file. |
Example
// load IndexedDb
instance.LoadIndexedDb("path");Example2
// load IndexedDb
$instance->LoadIndexedDb("path");LoadIndexedDb
Method
void LoadIndexedDb(Byte[] databases)
Loads indexedDB.
Parameters
| Type | Name | Description |
|---|---|---|
Byte[] | databases | The indexedDB data. |
SaveIndexedDb
Method
void SaveIndexedDb(string path)
Saves indexedDB.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to fonts. |
Example
// save IndexedDb
instance.SaveIndexedDb("path");Example2
// save IndexedDb
$instance->SaveIndexedDb("path");SaveIndexedDb
Method
Byte[] SaveIndexedDb()
Saves indexedDB.
Returns: The indexedDB data.
WaitForPreparing
Method
void WaitForPreparing()
Wait while instance prerpare all tabs.
StopDownloads
Method
void StopDownloads()
Stop the active downloads.
ClearCookie
Method
void ClearCookie(string domainFilter)
Clears the cookies.
Parameters
| Type | Name | Description |
|---|---|---|
string | 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();CheckAlive
Method
bool CheckAlive()
ClearCache
Method
void ClearCache(string domainFilter, bool storeCookie)
Clears the cache.
Parameters
| Type | Name | Description |
|---|---|---|
string | 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. |
bool | storeCookie | The true if need to store the cookies; otherwise false. |
Example
// clear cache
instance.ClearCache();Example2
// clear cache
$instance->ClearCache();SwitchPopupHandlerMode
Method
void SwitchPopupHandlerMode(bool record, string id)
Reserved function
Parameters
| Type | Name | Description |
|---|---|---|
bool | record | |
string | id |
NewTab
Method
Tab NewTab(string address)
Creates a new tab in the current instance.
Parameters
| Type | Name | Description |
|---|---|---|
string | 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
Tab GetTabByAddress(string address)
Returns tab by the address.
“page” - this is the default value for main tab. For popup uses the address “popup”.
Parameters
| Type | Name | Description |
|---|---|---|
string | 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
void ReleasePreparing(bool released)
Prepare before release instance.
Parameters
| Type | Name | Description |
|---|---|---|
bool | released |
CloseAllTabs
Method
void CloseAllTabs()
Closes all tabs except the main tab.
Example
// close all tabs
instance.CloseAllTabs();Example2
// close all tabs
$instance->CloseAllTabs();SetOkAlertPolicy
Method
void SetOkAlertPolicy(string answer, string id)
Sets the policy for pop-up Alert windows with one-click OK.
Parameters
| Type | Name | Description |
|---|---|---|
string | answer | The answer for the window. |
string | id | The id of project. The default value is empty string. |
SetOkCancelConfirmPolicy
Method
void SetOkCancelConfirmPolicy(string answer, string id)
Sets the policy for pop-up windows Confirm with OK and Cancel.
Parameters
| Type | Name | Description |
|---|---|---|
string | answer | The answer for the window of the authorization. This parameter can take the following values: “ok” or “cancel”. |
string | id | The id of project. The default value is empty string. |
SetCertificate
Method
void SetCertificate(string path, string pass)
Sets the certificate to browser.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path of certificate, witch extension is “.p12” or “.pfx”. |
string | pass | The password for certificate. |
SetJSValuePromptPolicy
Method
void SetJSValuePromptPolicy(string answer, string value, string id)
Sets the policy for pop-up Prompt windows with an input field value.
Parameters
| Type | Name | Description |
|---|---|---|
string | answer | The answer for the window of the authorization. This parameter can take the following values: “ok” or “cancel”. |
string | value | The value of the answer. |
string | id | The id of project. The default value is empty string. |
SetFileUploadPolicy
Method
void SetFileUploadPolicy(string answer, string value, string id)
Sets the policy for the windows of to send the file to the server.
Parameters
| Type | Name | Description |
|---|---|---|
string | answer | The answer for the window of the authorization. This parameter can take the following values: “ok” or “cancel”. |
string | value | The value of the answer. |
string | id | The id of project. The default value is empty string. |
SetAuthorizationPolicy
Method
void SetAuthorizationPolicy(string answer, string login, string pass, string id)
Sets the policy for the windows of the authorization.
Parameters
| Type | Name | Description |
|---|---|---|
string | answer | The answer for the window of the authorization. This parameter can take the following values: “ok” or “cancel”. |
string | login | The login for the window of the authorization. |
string | pass | The password for the window of the authorization. |
string | id | The id of project. The default value is empty string. |
SetCertificatesPolicy
Method
void SetCertificatesPolicy(string answer, string id)
Sets the policy for the window of making the certificate.
Parameters
| Type | Name | Description |
|---|---|---|
string | answer | The answer for the window. |
string | id | The id of project. The default value is empty string. |
SetDefaultPreference
Method
void SetDefaultPreference(string id)
Sets the all the default settings.
Parameters
| Type | Name | Description |
|---|---|---|
string | id | The id of project. The default value is empty string. |
Example
instance.SetDefaultPreference();Example2
$instance->SetDefaultPreference();SetProxy
Method
void SetProxy(string ip, int port, string type, string login, string password, bool useProxifier, bool emulateGeolocation, bool emulateTimezone, bool emulateWebrtc)
Sets the proxy to the instance.
The parameters login and password can be empty if authorization is not necessary.
Parameters
| Type | Name | Description |
|---|---|---|
string | ip | The IP address for the proxy. |
int | port | The port for the instance. |
string | type | The type of proxy. It’s can be http, socks4 or socks5 |
string | login | The login for authorization. |
string | password | The password for authorization. |
bool | useProxifier | The true if use proxifier; otherwise and default, false. |
bool | 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. |
bool | emulateTimezone | The true if need emulate timezone according with the ip; otherwise and default, false. |
bool | 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
void SetProxy(string proxyString, bool useProxifier, bool emulateGeolocation, bool emulateTimezone, bool emulateWebrtc)
Sets the proxy to the instance.
Parameters
| Type | Name | Description |
|---|---|---|
string | proxyString | The parameters of proxy. This string should has the follow format: [protocol://](login):(password)@:(port). For example: socks5://192.168.0.1:80 |
bool | useProxifier | The true if use proxifier; otherwise and default, false. |
bool | emulateGeolocation | The true if need emulate geolocation according with the ip; otherwise and default, false. |
bool | emulateTimezone | The true if need emulate timezone according with the ip; otherwise and default, false. |
bool | 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
void SetProxy(ProxySettings proxySettings, NetworkSettings networkSettings)
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
| Type | Name | Description |
|---|---|---|
ProxySettings | proxySettings | Class of proxy parameters |
NetworkSettings | 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;
}SetProxyExclusions
Method
void SetProxyExclusions(IEnumerable<string> exclusions)
Parameters
| Type | Name | Description |
|---|---|---|
IEnumerable<string> | exclusions |
SetHeader
Method
void SetHeader(string headerName, string value)
Sets the header for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Type | Name | Description |
|---|---|---|
string | headerName | The header name. |
string | 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
void SetHeader(NavigatorField field, string value)
Sets the header for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Type | Name | Description |
|---|---|---|
NavigatorField | field | The header name. |
string | 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
void SetUserHeader(string headerName, string value)
Sets the user header for tabs requests.
The method call is made before calling any other methods of an Instance object.
Parameters
| Type | Name | Description |
|---|---|---|
string | headerName | The header name. |
string | 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
void ShowNavigatorField(NavigatorField field)
Show navigator field for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Type | Name | Description |
|---|---|---|
NavigatorField | 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
void ShowNavigatorField(string field)
Show navigator field for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Type | Name | Description |
|---|---|---|
string | 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
void HideNavigatorField(NavigatorField field)
Hide navigator field for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Type | Name | Description |
|---|---|---|
NavigatorField | 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
void HideNavigatorField(string field)
Hide navigator field for tab.
The method call is made before calling any other methods of an Instance object.
Parameters
| Type | Name | Description |
|---|---|---|
string | 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
IEnumerable<PluginItem> GetPlugins()
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
void ShowPlugin(PluginItem plugin)
Show the plugin.
Parameters
| Type | Name | Description |
|---|---|---|
PluginItem | 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
void HidePlugin(PluginItem plugin)
Hide the plugin.
Parameters
| Type | Name | Description |
|---|---|---|
PluginItem | 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
void LoadPlugins(string path)
Loads plugins.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to plugins. |
Example
// load plugins
instance.LoadPlugins("path");Example2
// load plugins
$instance->LoadPlugins("path");LoadPlugins
Method
void LoadPlugins(Byte[] plugins)
Loads plugins.
Parameters
| Type | Name | Description |
|---|---|---|
Byte[] | plugins | The plugins data. |
SavePlugins
Method
void SavePlugins(string path)
Saves plugins.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to plugins. |
Example
// save plugins
instance.SavePlugins("path");Example2
// save plugins
$instance->SavePlugins("path");SavePlugins
Method
Byte[] SavePlugins()
Saves plugins.
Returns: The path to plugins.
LoadLocalStorage
Method
void LoadLocalStorage(string path)
Loads local storage.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to local storage data. |
Example
// load local storage
instance.LoadLocalStorage("path");Example2
// load local storage
$instance->LoadLocalStorage("path");LoadLocalStorage
Method
void LoadLocalStorage(Byte[] storage)
Loads local storage.
Parameters
| Type | Name | Description |
|---|---|---|
Byte[] | storage | The local storage data. |
SaveLocalStorage
Method
void SaveLocalStorage(string path)
Saves local storage.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to local storage data. |
Example
// save local storage
instance.SaveLocalStorage("path");Example2
// save local storage
$instance->SaveLocalStorage("path");SaveLocalStorage
Method
Byte[] SaveLocalStorage()
Saves local storage.
Returns: The local storage data.
GetProxy
Method
string GetProxy()
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
void ClearProxy()
Removes the proxy from the Instance object.
Example
// clear proxy
instance.ClearProxy();Example2
// clear proxy
$instance->ClearProxy();GetTemplateValue
Method
string GetTemplateValue(string stepId, string branchName)
Returns the value of a branch in the template for the specified step.
Parameters
| Type | Name | Description |
|---|---|---|
string | stepId | Id of step. |
string | branchName | The branch name. |
Returns: The value of a branch.
SetTemplateValue
Method
void SetTemplateValue(string stepId, string branchName, string value)
Sets the value of a branch in the template for the specified step.
Parameters
| Type | Name | Description |
|---|---|---|
string | stepId | Id of the step. |
string | branchName | The branch name. |
string | value | The value to set. |
EvaluateJavaScript
Method
string EvaluateJavaScript(string javaScript)
Evaluates localy the specified java script code (supports WSH objects).
Parameters
| Type | Name | Description |
|---|---|---|
string | 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.
Reload
Method
void Reload()
Reloads the current Instance object. Works only in ProjectMaker and ZennoPoster.
Launch
Method
void Launch(BrowserType browserType, bool useProfile)
Launches the instance with required built-in browser type. Works in ProjectMaker and ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
BrowserType | browserType | The required type of browser to launch. |
bool | useProfile | The true if need to use the current profile; otherwise false. |
Example
instance.Launch(ZennoLab.InterfacesLibrary.Enums.Browser.BrowserType.WithoutBrowser, true);Launch
Method
void Launch(BrowserType browserType, string browserArgs, bool useProfile)
Launches the instance with required built-in browser type and browser arguments. Works in ProjectMaker and ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
BrowserType | browserType | The required type of browser to launch. |
string | browserArgs | The command line arguments for starting browser. |
bool | useProfile | The true if need to use the current profile; otherwise false. |
Launch
Method
void Launch(BrowserType browserType, string browserArgs, string cachePath)
Launches the instance with required built-in browser type, browser arguments and folder-profile. Works in ProjectMaker and ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
BrowserType | browserType | The required type of browser to launch. |
string | browserArgs | The command line arguments for starting browser. |
string | cachePath | Path to the folder-profile folder. |
Launch
Method
void Launch(BrowserType browserType, string browserArgs, string cachePath, bool convertProfileFolder)
Launches the instance with required built-in browser type, browser arguments and folder-profile. Works in ProjectMaker and ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
BrowserType | browserType | The required type of browser to launch. |
string | browserArgs | The command line arguments for starting browser. |
string | cachePath | Path to the folder-profile folder. |
bool | convertProfileFolder | Convert CEF profile folder to Chromium profile folder. |
IntegrationLaunch
Method
void IntegrationLaunch(string profileId)
Launches integtated instance. Works in ProjectMaker and ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
string | profileId | The profile identifier in ZennoBrowser. |
Example
// Launch integrated browser
instance.IntegrationLaunch(project.Variables["id"].Value);IntegrationLaunch
Method
void IntegrationLaunch(string profileId, string workspaceId)
Launches integtated instance. Works in ProjectMaker and ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
string | profileId | The profile identifier in ZennoBrowser. |
string | workspaceId | The workspace identifier in ZennoBrowser. |
Example
// Launch integrated browser
instance.IntegrationLaunch(project.Variables["profileId"].Value, project.Variables["workspaceId"].Value);Launch
Method
void Launch(BrowserLaunchSettings launchSettings)
Launches the instance with settings object, allow to launch any browser type. Works in ProjectMaker and ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
BrowserLaunchSettings | 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
void Stop()
Stops the instance. Works in ProjectMaker and ZennoPoster.
Example
instance.Stop();SaveCookie
Method
void SaveCookie(string path)
Saves cookie.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to cookie. |
Example
// save cookie
instance.SaveCookie("path");Example2
// save cookie
$instance->SaveCookie("path");SaveCookie
Method
Byte[] SaveCookie()
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
void LoadCookie(string path)
Loads cookie.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | The path to cookie. |
Example
// load cookie
instance.LoadCookie("path");Example2
// load cookie
$instance->LoadCookie("path");LoadCookie
Method
void LoadCookie(Byte[] cookie)
Loads cookie.
Parameters
| Type | Name | Description |
|---|---|---|
Byte[] | 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
void SetCookie(string cookie)
Sets cookie.
Parameters
| Type | Name | Description |
|---|---|---|
string | 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
string GetCookie(string domain, bool isCookieFormat)
Gets cookie.
Parameters
| Type | Name | Description |
|---|---|---|
string | domain | The domain of cookie. The default value is empty string. |
bool | 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);