我需要测试一个聊天应用,我想测试的方式是打开一个chrome和另一个firefox的实例,并在两者之间发送消息。根据我所发现的,我可以打开两个浏览器会话,但它们是为同一个应用程序,并使用多能力来测试所有测试案例跨平台。有人尝试过吗?先谢谢你。
编辑:所以我把这个添加到我的protractor配置中,我已经尝试过在多个浏览器上测试同一个测试用例。
multicapabilities:[
{
browserName: 'chrome'
},
{
browserName: 'firefox'
}
]
我添加了这个,我能够在多个浏览器上独立运行同一个测试用例。
由于我需要一个测试用例在多个浏览器上运行。我发现我们可以使用 browser.forkNewDriverInstance()。这让我可以启动同一浏览器的多个窗口。这让我能够测试更多的场景。现在我需要能够在同一个测试用例中测试多个浏览器(firefox,chrome)。
如果需要提供更多信息,请告诉我。
在搜索了更多的stackoverflow页面和github问题后,我发现了这篇文章。我发现这篇文章 https:/github.comangularprotractorissues4962。. 这告诉我如何启动chrome和firefox一起在同一个测试用例.和代码,我用的是下面。
describe('Video Tests', () => {
let ffBrowser: ProtractorBrowser;
beforeAll(async () => {
ffBrowser = await protractor.browser.forkNewDriverInstance().ready;
(await ffBrowser.getProcessedConfig()).capabilities = {
'browserName': 'firefox',
'marionette': true,
'moz:firefoxOptions': {
'prefs': {
'media.navigator.streams.fake': true,
'media.navigator.permission.disabled': true
}
}
} // new caps goes here;
ffBrowser = await ffBrowser.restart();
});
it('testing cross browser', async () => {
await browser.get(browser.baseUrl);
await ffBrowser.get(browser.baseUrl);
await browser.sleep(5000);
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE
} as logging.Entry));
});
});