WebdriverIO & Browsermob

爱⌒轻易说出口 提交于 2019-12-22 22:23:49

问题


I'm currently trying to use Browsermob with WebdriverIO and I found this code on another answer, but when I run it, the firefox browser comes up and I see activity in the console windows I have selenium and browsermob-proxy running, but it does not go to the search.yahoo.com page. It just sits at a blank page and the tests ends (which says it passed, but that's something else) I'm running the latest WebdriverIO and Browsermob on a Mac Here's the code

var Proxy = require('browsermob-proxy').Proxy
    , webdriverio = require('webdriverio')
    , fs = require('fs')
    , proxy = new Proxy()
;

proxy.cbHAR('search.yahoo.com', doWebio, function(err, data) {
        if (err) {
            console.error('ERR: ' + err);
        } else {
            fs.writeFileSync('stuff.har', data, 'utf8');
        }
});

function doWebio(proxy, cb) {

    var browser = webdriverio.remote({
        host: 'localhost'
        , port: 4444
        , desiredCapabilities: { browserName: 'firefox', seleniumProtocol: 'WebDriver', proxy: { httpProxy: proxy } }
    });

    browser
        .init()
        .url("http://search.yahoo.com")
        .setValue("#yschsp", "javascript")
        .submitForm("#sf")
        .end().then(cb);        

}

回答1:


have you tried using chrome. Maybe it'll work. To do so:

  • Add chromedriver from here to your /usr/bin
  • make change to above code like below (note upper case P in proxy)
  • start selenium server and browserMob as usual and run the test

    desiredCapabilities: { browserName: 'chrome', seleniumProtocol: 'WebDriver', Proxy: { httpProxy: proxy } }




回答2:


For those who come to this, with FireFox, you now need GeckoDriver installed to use FireFox with Selenium. https://github.com/mozilla/geckodriver/releases

Also, the BrowserMob proxy hasn't had a release since 2016. The BrowserUp Proxy is an actively maintained drop-in replacement https://github.com/browserup/browserup-proxy with support up to Java 11, active development, brotli support, security fixes, and more.



来源:https://stackoverflow.com/questions/37010103/webdriverio-browsermob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!