WebdriverIO &浏览器 [英] WebdriverIO & Browsermob

查看:33
本文介绍了WebdriverIO &浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试将 Browsermob 与 WebdriverIO 一起使用,我在另一个答案中找到了此代码,但是当我运行它时,firefox 浏览器出现了,我在控制台窗口中看到了活动,我正在运行 selenium 和 browsermob-proxy,但它不会转到 search.yahoo.com 页面.它只是坐在一个空白页上,测试结束(它说它通过了,但那是别的东西)我在 Mac 上运行最新的 WebdriverIO 和 Browsermob这是代码

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

}

推荐答案

您是否尝试过使用 chrome.也许它会奏效.这样做:

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

  • 将来自此处的 chromedriver 添加到您的/usr/bin
  • 对上面的代码进行如下更改(注意代理中的大写 P)
  • 像往常一样启动 selenium 服务器和 browserMob 并运行测试

  • 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 } }

这篇关于WebdriverIO &浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆