如何使用Chrome配置文件无头运行Webdriver。

huangapple 未分类评论43阅读模式
英文:

How to run Webdriver headless with Chrome profiles

问题

我已经使用Chrome配置文件成功登录了一个网站... 但是希望浏览器不要显示出来,所以我在此之后添加了options.addArguments("user-data-dir=" + myProfilesPath);,但是之后它就不起作用了!请告诉我为什么无头参数与配置文件一起使用时不起作用?我该如何解决这个问题?

英文:

I have been use Chrome profiles to login a website it was success...! But want to browser not showing up so I added options.addArguments("user-data-dir="+myProfilesPath); after then it not working! Plzz tell me why headless argument not working with profiles? And How do I solve that problem?

答案1

得分: 0

ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com/");
英文:
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
WebDriver driver  = new ChromeDriver(options);
driver.get("https://www.google.com/");

huangapple
  • 本文由 发表于 2020年4月4日 13:08:17
  • 转载请务必保留本文链接:https://java.coder-hub.com/61024035.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定