Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: browser.init is not a function #33

Open
hubitor opened this issue Feb 28, 2019 · 5 comments
Open

TypeError: browser.init is not a function #33

hubitor opened this issue Feb 28, 2019 · 5 comments

Comments

@hubitor
Copy link

hubitor commented Feb 28, 2019

I'm seeing this error:

DEBUG @wdio/config: @wdio/sync found, running tests synchronous
mytest/node_modules/browsermob-proxy/index.js:36
            .init()
             ^

TypeError: browser.init is not a function
    at Proxy.selFunc (mytest/node_modules/browsermob-proxy/index.js:36:14)
    at mytest/node_modules/browsermob-proxy/index.js:171:31
    at mytest/node_modules/browsermob-proxy/index.js:140:25
    at IncomingMessage.<anonymous> (mytest/node_modules/browsermob-proxy/index.js:232:21)
    at IncomingMessage.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1103:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

for every example I've tried including the example from here:

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

proxy.doHAR('http://yahoo.com', function (err, data) {
    if (err) {
        console.error('ERROR: ' + err);
    } else {
        fs.writeFileSync('yahoo.com.har', data, 'utf8');
    }
});

I start browsermob-proxy like this:
$ /bin/sh /home/user/browsermob-proxy-2.1.4/bin/browsermob-proxy

and Selenium Server like this:
./node_modules/webdriver-manager/bin/webdriver-manager start --standalone

@barocsi
Copy link

barocsi commented Nov 16, 2019

It seems there is an issue with the webdriverio initialization at index.js line 36:
<rejected> Error: Required option "capabilities" is missing
Did you manage to resolve this issue?

@hubitor
Copy link
Author

hubitor commented Nov 16, 2019

Nope. I was using this:
https://github.com/cyrus-and/chrome-har-capturer
lately.

@lasertiger
Copy link

I have the same problem.

@kalpeshchilka
Copy link

I am facing a similar issue. How to fix this? Is there any alternative repo and blog to help with this.

@franzcatch
Copy link

I am facing the same problem.

This seems to be the offending line:
https://github.com/zzo/browsermob-node/blob/master/index.js#L35

I put a console.log(browser) just above it and what comes out is a Promise. So webdriverio.remote appears to be returning a promise. I am not super well versed in this, but I am trying to pair this with Protractor - which uses webdriver-manager. The version I am running is 12.1.7. Running webdriver-manager status reveals the following versions:

[11:06:52] I/status - selenium standalone version available: 3.141.59 [last]
[11:06:52] I/status - chromedriver version available: 83.0.4103.39 [last]
[11:06:52] I/status - geckodriver version available: v0.26.0 [last]
[11:06:52] I/status - android-sdk is not present
[11:06:52] I/status - appium is not present

It appears that the webdriverio inside selenium 3.141.59 must have had some fundamental functionality changes since the last time browsermob-node was updated. Thing is, I don't know which version I "should" be running that is compatible with the latest version of browsermob-node.

Just for grins, I modified my local version of browsermob-node like this:

    selFunc:  async function(proxy, url, cb) {
        var browser = await webdriverio.remote({
            host: this.selHost
            , port: this.selPort
            , capabilities: { browserName: 'firefox', seleniumProtocol: 'WebDriver', proxy: { httpProxy: proxy } }
            , desiredCapabilities: { browserName: 'firefox', seleniumProtocol: 'WebDriver', proxy: { httpProxy: proxy } }
        });

        browser
            .init()
            .url(url)
            .end(cb);
    },

Note that webdriverio.remote was also complaining about capabilities missing - so I copied desiredCapabilities to it.

This no longer blows up with the error shown in the OP above, but I am still not able to capture any traffic. Likely more compatibility issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants