48 public class BrowserSettings
50 internal IBrowser Browser {
get;
set; }
51 internal bool ObeyRobotsTxt {
get;
set; } =
false;
52 internal bool RespectRobotMetaTags {
get;
set; } =
false;
53 internal List<string> RobotsTxt {
get;
set; }
54 internal Dictionary<int, TabInfo> TabIdsToURL {
get;
set; } =
new Dictionary<int, TabInfo>();
55 internal Dictionary<string, URLInfo> URLsToTabId {
get;
set; } =
new Dictionary<string, URLInfo>();
56 internal Dictionary<string, WindowInfo> WindowIdsToURL {
get;
set; } =
new Dictionary<string, WindowInfo>();
58 internal string BrowserName {
get;
set; } =
null;
59 internal string DriverLocation {
get;
set; } =
null;
60 internal int ServiceDriverPid {
get;
set; } = 0;
62 internal bool LoadImages {
get;
set; } =
false;
64 internal bool OpenPDFExternally {
get;
set; } =
false;
66 internal bool PromptForDownload {
get;
set; } =
true;
70 internal bool? DialogsAccepted {
get;
set; } =
null;
73 internal string DialogText {
get;
set; } =
null;
76 internal List<Browser.CallOnFailDelegate> CallOnFail {
get;
set; } =
new List<Browser.CallOnFailDelegate>();
81 internal DateTime? CredentialsPresented {
get;
set; }
83 internal List<string> DownloadFileTypeList {
get;
set; } =
null;
85 internal List<string> OpenFileTypeList {
get;
set; } =
null;
87 internal bool WaitOnDocumentReady {
get;
set; } =
true;
88 internal bool WaitOnNetworkIdle {
get;
set; } =
false;
89 internal int NetworkIdleTimeoutMs {
get;
set; } = 30_000;
90 internal int NetworkIdleMaxConnections {
get;
set; } = 0;
91 internal int NetworkIdlePruneMs {
get;
set; } = 3_000;
92 internal bool TempProfileCreated {
get;
set; } =
false;
93 internal bool DownloadBehaviorSet {
get;
set; } =
false;
94 internal Dictionary<string, JToken> PreviousDownloadPreferences {
get;
set; } =
null;
96 internal Dictionary<string, string> PreviousFirefoxPreferences {
get;
set; } =
null;
98 internal string DefaultProfileDataDirectory {
get;
set; }
103 internal string ProfileDataDirectory {
get;
set; }
104 internal string ProfileName {
get;
set; }
105 internal string ProfileUserName {
get;
set; }
107 internal BrowserType BrowserType {
get;
set; } = BrowserType.Chrome;
108 internal string PlatformName {
get;
set; } =
"Windows 10";
111 internal bool UseExistingBrowser {
get;
set; } =
false;
112 internal int? ExistingBrowserPort {
get;
set; } =
null;
115 internal int? DebugPort {
get;
set; }
116 internal bool DebugPipe {
get;
set; }
117 public PipeStream InboundPipe {
get;
set; }
118 public PipeStream OutboundPipe {
get;
set; }
119 public PipeStream ErrorPipe {
get;
set; }
120 internal string PuppeteerUrl {
get;
set; }
124 internal bool CaptureCalls {
get;
set; } =
false;
128 internal string CallFilter {
get;
set; }
131 internal bool CaptureUnavailableReported {
get;
set; } =
false;
133 PuppeteerCommunicator _puppeteerCommunicator =
null;
137 internal bool HasPuppeteerCommunicator =>
null != _puppeteerCommunicator;
139 internal PuppeteerCommunicator PuppeteerCommunicator
143 if (
null == _puppeteerCommunicator &&
true == UsePuppeteer)
145 if (
null == PuppeteerUrl)
153 GPAL.
PublishSimpleEvent(GPALEventType.ERROR, $
"A Puppeteer connection was asked for before [{BrowserType}] had a debugging port, so it is pointed at [{ours}] where nothing is listening rather than at another browser",
this, GPALObjectType.Browser);
155 PuppeteerUrl = $
"http://localhost:{ours}";
161 _puppeteerCommunicator =
new PuppeteerCommunicator(PuppeteerUrl, Browser, DebugPipe, CaptureCalls);
163 else if (
null == _puppeteerCommunicator &&
false == UsePuppeteer)
167 _puppeteerCommunicator =
new PuppeteerCommunicator();
170 return _puppeteerCommunicator;
174 _puppeteerCommunicator = value;
179 get => PuppeteerCommunicator?.PuppeteerClient;
180 set => PuppeteerCommunicator.PuppeteerClient = value;
182 internal bool FullScreen {
get;
set; } =
false;
183 internal bool Maximize {
get;
set; } =
false;
184 internal bool Minimize {
get;
set; } =
false;
185 public bool UseHardware {
get => AutomationEngine.OttoMagicHW == AutomationEngine || AutomationEngine.PuppeteerPipeHW == AutomationEngine || AutomationEngine.PuppeteerPortHW == AutomationEngine || AutomationEngine.SeleniumHW == AutomationEngine; }
186 public bool UseJavaScript {
get => AutomationEngine.OttoMagic == AutomationEngine || AutomationEngine.SeleniumJS == AutomationEngine; }
187 public bool UseOttoMagic {
get => AutomationEngine.OttoMagic == AutomationEngine || AutomationEngine.OttoMagicHW == AutomationEngine; }
188 public bool UsePuppeteer {
get => AutomationEngine.PuppeteerPipe == AutomationEngine || AutomationEngine.PuppeteerPort == AutomationEngine || AutomationEngine.PuppeteerPortHW == AutomationEngine || AutomationEngine.PuppeteerPipeHW == AutomationEngine; }
189 public bool UseSelenium {
get => AutomationEngine.Selenium == AutomationEngine || AutomationEngine.SeleniumJS == AutomationEngine || AutomationEngine.SeleniumHW == AutomationEngine; }
191 public AutomationEngine AutomationEngine {
get;
set; } = AutomationEngine.PuppeteerPort;
194 internal bool HiddenDesktop {
get;
set; } =
false;
203 internal bool HiddenDesktopReported {
get;
set; } =
false;
207 internal bool HiddenDesktopChecked {
get;
set; } =
false;
208 internal int WaitForDocumentReadyTimeoutMs {
get;
set; } = 30_000;
212 internal int NavigationGraceMs {
get;
set; } = 250;
214 internal int WithAllThatMatch {
get;
set; } =
int.MaxValue;
216 internal string RestApiBaseUrl {
get;
set; }
219 internal bool AttachedRestApi {
get;
set; }
231 internal set => _magicHelper = value;
241 internal void DetachFromRunningBrowser(
Browser browser)
244 BrowserDriver =
null;
246 RestApiBaseUrl =
null;
248 _puppeteerCommunicator =
null;
250 internal StealthType StealthType {
get;
set; } = StealthType.None;
251 internal bool StealthApplied {
get;
set; } =
false;
252 internal string CurrentURL {
get;
set; }
253 private GPALUrl _currentGPALUrl =
null;
254 internal GPALUrl CurrentGPALUrl
256 get => _currentGPALUrl;
259 _currentGPALUrl = value;
260 StorageActionToRun =
new StorageAction();
263 internal List<GPALUrl> GPALUrlList {
get;
set; }
264 internal string Referrer {
get;
set; } =
null;
265 internal string OverrideUserAgent {
get;
set; } =
null;
269 internal bool UserAgentFromBrowser {
get;
set; } =
false;
270 internal Selector CurrentSelector {
get;
set; } =
null;
271 internal IWebDriver BrowserDriver {
get;
set; } =
null;
272 internal System.Windows.Forms.Form CurrentForm {
get;
set; } =
null;
273 internal int WaitForWindowTimeoutInSeconds {
get;
set; } = 30;
274 internal bool BlockPopUps {
get;
set; } =
true;
275 internal int DownloadTimeoutInSec {
get;
set; } = 10;
276 internal bool UseDirectDownload {
get;
set; } =
false;
277 internal string DownloadLocation {
get;
set; }
278 internal bool DeleteFileBeforeDownload {
get;
set; } =
false;
279 internal bool OpenInTab {
get;
set; } =
false;
280 internal bool UseHeadless {
get;
set; } =
false;
281 internal bool? FileDownloaded {
get;
set; }
282 internal bool ScrollIntoView {
get;
set; } =
false;
283 internal Rectangle WindowSize {
get;
set; }
284 internal Size SavedWindowSize {
get;
set; }
285 internal PageOrientation PageOrientation {
get;
set; }
286 internal object JavaScriptResultObj {
get;
set; }
287 internal string JavaScriptResultStr {
get;
set; }
288 internal StorageAction StorageActionToRun {
get;
set; }
289 internal bool StorageActionCalled {
get;
set; }
291 internal string Version =
string.Empty;
292 internal int ServerResponseCode {
get;
set; }
294 internal Bitmap ScreenShot;
295 internal Process Process {
get;
set; } =
null;
296 internal int WhileLoopTimeoutMs {
get;
set; } = 30000;
297 internal int WhileLoopMaxIterations {
get;
set; } = 1000;
298 internal List<Action<IBrowser>> Workflows {
get;
set; }
299 internal BrowserSettings(Browser browser)
301 DownloadFileTypeList =
new List<string>();
302 OpenFileTypeList =
new List<string>();
303 WindowSize =
new Rectangle();
304 SavedWindowSize =
new Size();
305 Workflows =
new List<Action<IBrowser>>();
307 PageOrientation = PageOrientation.Portrait;
308 RobotsTxt =
new List<string>();
309 StorageActionToRun =
new StorageAction();
310 StorageActionCalled =
false;
311 GPALUrlList =
new List<GPALUrl>();