WebdriverIO & Browsermob
Asked Answered
M

2

2

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);        

}
Mahogany answered 3/5, 2016 at 17:0 Comment(1)
How do you stub the responses that are made in the browser - but not initiated explicitly by the test?Acquaintance
R
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 } }

Riesling answered 3/5, 2016 at 18:21 Comment(0)
S
0

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.

Secretin answered 7/7, 2019 at 19:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.