程式碼如下
public partial class Form1 : Form { private readonly ChromiumWebBrowser browser; private static readonly bool DebuggingSubProcess = Debugger.IsAttached; private ISelenium selenium; private StringBuilder verificationErrors; public Form1() { InitializeComponent(); var settings = new CefSettings(); settings.RemoteDebuggingPort = 8088; settings.IgnoreCertificateErrors = true; Cef.Initialize(settings); browser = new ChromiumWebBrowser(url) { Dock = DockStyle.Fill, }; browser.CreateControl(); this.Controls.Add(browser); } public static void GO() { var driverService = ChromeDriverService.CreateDefaultService(); driverService.HideCommandPromptWindow = true; ChromeOptions options = new ChromeOptions(); options.DebuggerAddress = "127.0.0.1:8088"; options.AddArguments("--enable-logging"); using (var driver = new ChromeDriver(driverService, options)) { //doSomething } } private void button1_Click(object sender, EventArgs e) { GO(); } }
沒有留言:
張貼留言