我们有时希望对一个已经打开的浏览器进行测试。

1.使用Debug 方式启动浏览器

 

 Process proc = new Process();
 proc.StartInfo.FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
 proc.StartInfo.Arguments = "https://www.intellitect.com/blog/ --new-window --remote-debugging-port=9222 --user-data-dir=C:\\Temp";
 proc.Start();

 2. 创建WebDriver并将浏览器的连接地址和端口作为参数传递给WebDriver 

  ChromeOptions options = new ChromeOptions();
  ptions.DebuggerAddress = "127.0.0.1:9222";
  var webDriver = new ChromeDriver(options);

 这样就可以对已经存在的浏览器进行操作了。

相关文章:

  • 2021-08-13
  • 2021-09-15
  • 2021-04-13
  • 2021-09-29
  • 2022-12-23
  • 2021-12-11
猜你喜欢
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
  • 2021-04-19
  • 2022-12-23
相关资源
相似解决方案