禁用带有WebdriverJS的GhostDriver,PhantomJS的控制台日志

时间:2016-10-10 07:03:59

标签: node.js selenium-webdriver phantomjs ghostdriver webdriverjs

当我们使用webdriverjs运行phantomjs(ghost驱动程序)时,我一直试图弄清楚如何禁用恼人的控制台日志,但是徒劳无功。

[INFO  - 2016-10-09T14:57:15.039Z] GhostDriver - Main - running on port 62381
[INFO  - 2016-10-09T14:57:15.084Z] Session [aa75cc80-8e30-11e6-8da5-a561819d4151] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1","webSecurityEnabled":true}
[INFO  - 2016-10-09T14:57:15.084Z] Session [aa75cc80-8e30-11e6-8da5-a561819d4151] - page.customHeaders:  - {}
[INFO  - 2016-10-09T14:57:15.084Z] Session [aa75cc80-8e30-11e6-8da5-a561819d4151] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"mac-10.10 (Yosemite)-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2016-10-09T14:57:15.084Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: aa75cc80-8e30-11e6-8da5-a561819d4151

以下是我的配置:

var webdriver = require('selenium-webdriver');
var phantomjs_exe = require('phantomjs-prebuilt').path;
var customPhantom = webdriver.Capabilities.phantomjs();
customPhantom.set("phantomjs.binary.path", phantomjs_exe);

//build custom phantomJS driver
var driver = new webdriver.Builder().
             withCapabilities(customPhantom).
             build();

从我这边做的事情 -

  • 通过各种SO线程但是所有这些线程都在java api绑定中有解决方案/方法。我正在寻找nodejs解决方案。以下是建议的事项:

  • Logger.getLogger(PhantomJSDriverService.class.getName()).setLevel(Level.OFF)

  • Silence ghostdriver.log

    import os
    driver = webdriver.PhantomJS(service_log_path=os.path.devnull);
    
  • 使用所需功能:

    DesiredCapabilities dcap = new DesiredCapabilities();
    String[] phantomArgs = new  String[] {"--webdriver-loglevel=NONE"};
    dcap.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);
    PhantomJSDriver phantomDriver = new PhantomJSDriver(dcap);
    

如何在 nodejs webdriver api绑定中执行这些操作?任何人都可以指导正确的方向吗?我发现很少有api doc示例没用!

0 个答案:

没有答案