在 Protractor 测试中获取当前浏览器名称 [英] Get the current browser name in Protractor test

查看:22
本文介绍了在 Protractor 测试中获取当前浏览器名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一些测试中创建用户.由于它连接到后端并创建真正的用户,因此我需要夹具.我正在考虑使用浏览器名称来创建唯一用户.然而,事实证明,要达到它是相当困难的......

谁能给我指出正确的方向?

解决方案

橡皮擦的另一个案例:)

答案其实很简单.

在我的 onPrepare 函数中,我添加了以下函数,它完美无缺.

browser.getCapabilities().then(function (cap) {browser.browserName = cap.caps_.browserName;});

我可以使用 browser.browserName 在我的测试中访问名称.

I'm creating users in some test. Since it is connected to the backend and create real users I need fixtures. I was thinking of using the browser name to create unique user. However, It has proven to be quite difficult to get to it...

Anyone can point me in the right direction?

解决方案

Another case of rubber ducking :)

The answer was actually quite simple.

in my onPrepare function I added the following function and it works flawlessly.

browser.getCapabilities().then(function (cap) {
  browser.browserName = cap.caps_.browserName;
});

I can get access the name in my test using browser.browserName.

这篇关于在 Protractor 测试中获取当前浏览器名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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