强制硒等待AngularJS [英] Force Selenium to wait for AngularJS

查看:157
本文介绍了强制硒等待AngularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以强制蟒蛇硒等待一秒钟,直到AngularJS完成页面解析,并加载了一些东西,它需要。

How can I force python Selenium wait for a second until AngularJS completes page parsing and loads some stuff that it needs.

或者我怎么能强迫硒等待按钮点击后1秒,这将导致Ajax请求到服务器上,通过AngularJS处理。我需要服务器端的操作来导航到其他页面之前发生。

Or how can I force Selenium to wait for 1 second after button click, which causes ajax request to the server, handled by AngularJS. I need server side actions to take place before navigating to other page.

推荐答案

访问AngularJS范围通过硒 - 最有可能的状态在范围已经举行/ IsolatedScope

Access AngularJS scope through Selenium - most likely that state is already held in Scope/IsolatedScope .

我建了一些扩展,以帮助这一点,可以转化为蟒蛇。

I built a few extensions to help with this that can be translated to python.

webDriver.NgWaitFor(productDiv, "scope.Data.Id != 0");
webDriver.NgWaitFor(partialElement, "scope.IsBusyLoadingTemplate == false");

<一个href=\"https://github.com/leblancmeneses/RobustHaven.IntegrationTests/blob/master/NgExtensions/NgWebDriverExtensions.cs\" rel=\"nofollow\">https://github.com/leblancmeneses/RobustHaven.IntegrationTests/blob/master/NgExtensions/NgWebDriverExtensions.cs

处理Ajax请求时angularjs $ HTTP和jQuery双方你的工作我使用的:

to deal with ajax request when your working with both angularjs $http and jquery I use:

webDriver.WaitFor("window.isBrowserBusy() == false");

要求你在这两个angularjs和jQuery设置拦截管理XHR请求的数量。

requires you to setup intercepts in both angularjs and jquery to manage the count of the xhr requests.

下面是我们使用在我们的项目的框架:(您可能希望从中提取多件)

Here is the framework we are using in our project: (you might want to extract more pieces from it)

https://github.com/leblancmeneses/RobustHaven.IntegrationTests

这篇关于强制硒等待AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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