I would like to open **Browser Console** for my session every time I launch Firefox.
Browser : Firefox v 61
How can you launch Browser Console for firefox:
1. open firefox (and give any URL )
2. Press Ctrl+Shift+J (or Cmd+Shift+J on a Mac)
Link : https://developer.mozilla.org/en-US/docs/Tools/Browser_Console
else if (browser.Equals(Constant.Firefox))
{
var profileManager = new FirefoxProfileManager();
FirefoxProfile profile = profileManager.GetProfile("ConsoleLogs");
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(DrivePath);
service.FirefoxBinaryPath = DrivePath;
profile.SetPreference("security.sandbox.content.level", 5);
profile.SetPreference("dom.webnotifications.enabled", false);
profile.AcceptUntrustedCertificates = true;
FirefoxOptions options = new FirefoxOptions();
options.AcceptInsecureCertificates = true;
options.Profile = profile;
options.SetPreference("browser.popups.showPopupBlocker", false);
driver = new FirefoxDriver(service.FirefoxBinaryPath, options, TimeSpan.FromSeconds(100));
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
}
batファイルを作成してコードに渡そうとしましたが、このバッチファイルはFirefoxブラウザーの新しい別のセッションを作成します。これは私が望むものではありません。自動化のために現在のセッションでブラウザーコンソールを起動したいと思います。
cd C:\Program Files\Mozilla Firefox
firefox -jsconsole
pause
このためのコード:
Process p = new Process();
p.StartInfo.FileName = @"C:\Users\Com\Desktop\batch\FirefoxConsole.bat";
p.Start();
Thread.Sleep(2000);
私が今探しているもの:可能であれば、SeleniumFirefoxプロファイルで「-jsconsole」を渡したいと思います。
C:\ Program Files \ Mozilla Firefox> firefox.exe -jsconsole
そして私はそれを行う方法がわかりません。
we just need to add this line in code where we initialing Firefox
options.AddArgument("--jsconsole");
else if (browser.Equals(Constant.Firefox))
{
var profileManager = new FirefoxProfileManager();
FirefoxProfile profile = profileManager.GetProfile("ConsoleLogs");
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(DrivePath);
service.FirefoxBinaryPath = DrivePath;
profile.SetPreference("security.sandbox.content.level", 5);
profile.SetPreference("dom.webnotifications.enabled", false);
profile.AcceptUntrustedCertificates = true;
FirefoxOptions options = new FirefoxOptions();
**options.AddArgument("--jsconsole");**
options.AcceptInsecureCertificates = true;
options.Profile = profile;
options.SetPreference("browser.popups.showPopupBlocker", false);
driver = new FirefoxDriver(service.FirefoxBinaryPath, options, TimeSpan.FromSeconds(100));
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加