量角器,AngularJS,解析

编程入门 行业动态 更新时间:2024-10-27 16:36:23
本文介绍了量角器,AngularJS,解析 - 量角器不会等待角度来解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是新来量角器和AngularJS。我使用的后端解析。试图做一个非常简单的测试:

I am new to Protractor and AngularJS. I'm using Parse on the back end. Trying to do a very simple test:

describe('Test', function () { beforeEach(function () { browser.get('index.html#/example') }); it('should have a button', function () { expect(element(by.css('#test321')).isElementPresent()).toBe(true); //fails }); ...

测试失败。该元件处于template.html:

The test fails. The element is in template.html:

... <body> <button id="test321">stuff</button> ...

它是由角路线加载。这条路线也是从后端加载数据:

It is loaded by angular-route. This route also loads data from back end:

... config(['$routeProvider', function ($routeProvider) { $routeProvider. when('/example', { templateUrl: 'template.html', controller: 'templateCtrl', resolve: { data: 'dataService' //Data is loaded from Parse. This line causes the problem }...

的问题是由引起数据:上面的行。如果我采取的线路输出,或使其返回静态结果,它工作正常。另外,如果我提出这个元素的index.html它的工作原理也是如此。

The problem is caused by the "data:" line above. If I take that line out, or have it return static result it works fine. Also if I move this element index.html it works as well.

这似乎是一个时间问题。不过根据文档量角器(或专门isElement present)定位元素之前等待各项决议。

This seems like a timing issue. However according to the documentation protractor (or specifically isElementPresent) waits for all resolutions before locating elements.

我跺着脚。非常感谢任何帮助。

I'm stomped. Many thanks for any help.

更新:根据这这是在量角器1.2解决了,但我上1.4。很奇怪的。

Update: According to this this was solved in Protractor 1.2, but I'm on 1.4. Very strange.

推荐答案

因为它是一个时机的问题,解决方法可以等待元素是present你断言,这是present前:

Since it's a timing issue, a workaround can be to wait for the element to be present before you assert that it's present:

describe('Test', function () { beforeEach(function () { browser.get('index.html#/example') }); it('should have a button', function () { browser.wait(function() { return $('#test321').isPresent(); // keeps waiting until this statement resolves to true }, timeToWaitInMilliseconds, 'message to log to console if element is not present after that time'); expect($('#test321').isPresent()).toBe(true); }); ...

更多推荐

量角器,AngularJS,解析

本文发布于:2023-11-22 23:12:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619292.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:量角器   AngularJS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!