我正在编写一个potractor测试用例来下载一个可以是任何类型的文件.
__PRE__
我现在如何检查文件是否正确下载.
鉴于我正在构建我的angularjs量角器e2e测试套件,利用页面对象模式.
我尽可能合理地将页面对象代码分隔在不同的文件中.
什么是启用页面对象继承的好方法?javascript经典继承?基于Object.create()的继承?其他?
我应该在页面对象中保持期望吗?或者通过将他们转移到断言库来支持Martin Fowler optinion?在这种情况下,这个javascript-nodejs技术堆栈中究竟会是什么样子?
我在这里准备了一个现场jsfiddle游乐场,所以你可以试试你的改进.
或者只是在答案中粘贴代码,为了清楚起见,我会粘贴下面的jsfiddle内容:
"use strict";
// A Page Object is a Singleton, so no need to constructors or classic js inheritance,
// please tell me if I'm wrong or what's the utility of creating a (new LoginPage())
// every time a spec need to use this login page.
var loginPage = {
// Page Object Elements
userElm: $('.user.loginPage'),
// Page Object Assertions
// Martin Fowler [doesn't favor](http://martinfowler.com/bliki/PageObject.html) …Run Code Online (Sandbox Code Playgroud) 我有一个Angular应用程序需要与Google进行身份验证,授予一些范围等,我正在尝试为它设置自动e2e测试.我的量角器一般都适合我,但是当我们进入google auth页面,登录并重定向时,量角器未通过测试,因为"文档在等待结果时被卸载".
在每次测试之前,我是否可以使用工具或技术对开发Google帐户进行身份验证?
如果我可以让框架保持一秒,而普通的webdriver驱动登录,并且只有在我到达目标页面后才真正激活角度内容,那将是完美的!
我正在将我的karma-ng-scenario测试套件迁移到量角器.我想做点什么
// karma-ng-scenario
expect(element('legend').text()).not().toBe("LOGIN_CONNECT");
Run Code Online (Sandbox Code Playgroud)
在量角器的方式.但似乎没有not()功能.
我正在使用angular-translateLONGIN_CONNECT字符串绑定到多种语言,我想测试字符串是否已翻译.
更全球化,如果有什么不同,有没有方法测试?...没有课程,页面上不存在,未选中,...
我在这里有一个有趣的设置.
我有一个Angular应用程序在iframe中加载另一个Angular App.我有兴趣用Protractor测试iframed-in Angular应用程序.
量角器正在等待加载的第一个Angular应用程序,但当我切换iframe时
ptor.switchTo().frame('experience');
Run Code Online (Sandbox Code Playgroud)
我可以看到Protractor在进行断言之前没有等待iframed Angular应用程序.我试过添加
ptor.waitForAngular();
Run Code Online (Sandbox Code Playgroud)
切换到iframe没有运气.任何人都有任何想法在这里发生了什么?
谢谢!
如果它有帮助,我正在通过Chrome上的Saucelabs ssh隧道运行我的测试.我可以说隧道工作正常,因为我看到iframed应用程序的资源被请求和下载.
我们的(PHP)应用程序需要设置某些cookie才能加载Angular.js客户端应用程序.如果未设置cookie,则抛出异常并显示错误页面.
这意味着为了运行E2E测试,我们需要设置cookie,但是下面的失败是因为Protractor试图在browser.get调用之后立即找到Angular (它不存在因为抛出了异常).
browser.get('http://' + domain + '/');
browser.manage().addCookie('foo', 'boo', '/', domain);
Run Code Online (Sandbox Code Playgroud)
browser.get设置完cookie后我试着打电话:
browser.manage().addCookie('foo', 'boo', '/', domain);
browser.get('http://' + domain + '/');
Run Code Online (Sandbox Code Playgroud)
但是这会产生以下错误:
无法在"文档"上设置"cookie"属性:在"data:"URL中禁用Cookie.
有办法如何处理这种情况?或许告诉量角器在进行第一次browser.get调用时不检查Angular,或者在调用获取URL之前以某种方式为我们的域设置cookie?
我正在测试主要在angularjs中编写的应用程序,但应用程序的某些元素是用.NET C#编写的,例如登录表单.
我的问题是这个.
我可以利用Protractor并通过e2e测试完全测试我的应用程序.
我尝试过使用量角器,到目前为止我很满意.但是,我似乎无法测试用.NET编写的页面.我不确定这是不是因为量角器只测试角度应用程序的元素,或者是否是我编写测试的方式.
我试过在页面中搜索元素,如下例所示.
ptor.findElement(protractor.By.xpath('/html/body/div/div[1]/section/input')).sendKeys('xxx');
Run Code Online (Sandbox Code Playgroud)
但这只会返回一个UnknownError:javascript错误:无法调用未定义的方法'get'.
我知道这个错误意味着元素在页面上不可见但是我在下面显示的测试中放置了超时
it('this is a test', function() {}, 10000);
我要求的是能够将文本添加到由...创建的动态创建的输入框中 Html.TextBoxFor()
铬版本:57.0.2987.98米(64位)
"protractor": "4.0.11",
"protractor-console-plugin": "0.1.1",
"protractor-jasmine2-html-reporter": "0.0.6",
"protractor-notify-plugin": "1.0.0",
Run Code Online (Sandbox Code Playgroud)
量角器无法启动chrome并出现以下错误:
unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=57.0.2987.98)
(Driver info: chromedriver=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.10 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
Run Code Online (Sandbox Code Playgroud) 我有一个Angularjs应用程序,在执行某些操作之前使用简单的javascript确认.
function TokenController($scope) {
$scope.token = 'sampleToken';
$scope.newToken = function() {
if (confirm("Are you sure you want to change the token?") == true) {
$scope.token = 'modifiedToken';
}
};
}
Run Code Online (Sandbox Code Playgroud)
<div id="tokenDiv">
Token:{{token}} <button ng-click="newToken()">New Token</button>
</div>
Run Code Online (Sandbox Code Playgroud)
现在我想要进行端到端测试以检查在视图中是否正确替换了令牌.如何拦截javascript.confirm()呼叫,以便它不会停止执行测试?
it('should be able to generate new token', function () {
var oldValues = element('#tokenDiv').text();
element('button[ng-click="newToken()"]').click(); // Here the javascript confirm box pops up.
expect(element('#tokenDiv').text()).not.toBe(oldValues);
});
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已经尝试重新定义window.confirm函数,但实际的调用抱怨它是未定义的.
我也想设置一个Jasmine间谍,window.confirm但是在下面的语法中,spyOn(window, 'confirm');它给了我一个错误,说你不能窥探null …
我正在尝试针对我的本地服务器运行e2e测试并测试生成的url(在单击导航按钮之后)是正确的结果.但是,生成的url始终为false.
我的代码如下所示:
HTML:
//http://localhost/#/current_Page
<html>
<head><title></title></head>
<body>
//should change the current url to
//http://localhost/#/new_page
<button class="button" ng-click="change_page()">Change Page</button>
</html>
Run Code Online (Sandbox Code Playgroud)
测试代码:
var protractor = require('protractor');
require('protractor/jasminewd');
describe('Tests', function() {
var ptor;
describe('Test 1', function() {
var ptor = protractor.getInstance();
ptor.get('#/current_page');
it('change page and current url', function() {
ptor.findElement(protractor.By.className('.button').click().then(function() {
expect(ptor.currentUrl()).toContain('#/new_page');
});
});
}, 30000);
});
Run Code Online (Sandbox Code Playgroud)
问题是单击按钮后的当前URL仍为#/ current_url,并且未更改为预期结果#/ new_page.
有谁知道我哪里出错了?
angularjs-e2e ×10
protractor ×9
angularjs ×8
.net ×1
automation ×1
c# ×1
jasmine ×1
javascript ×1
karma-runner ×1
node.js ×1
oauth ×1
selenium ×1