开发者

Why does my Selenium command not work?

开发者 https://www.devze.com 2023-02-25 13:13 出处:网络
I\'m writing a selenium script that should only start testing after all ajax calls have completed. Several forums have suggested that I use the following condition (in the waitForCondition command):

I'm writing a selenium script that should only start testing after all ajax calls have completed.

Several forums have suggested that I use the following condition (in the waitForCondition command):

selenium.browserbot.getCurrentWindow().jQuery.active == 0

Unfortunately this keeps throwing an开发者_StackOverflow社区 error:

jQuery is undefined

JQuery is definitely defined on my site. I have also tried substituting the jQuery with $, but get the same error.

Any ideas?


You might need to wait for jQuery to have finished loading, try waiting until

typeof selenium.browserbot.getCurrentWindow().jQuery == 'function'

is true, before checking active.


You should use selenium.browserbot.getUserWindow().$.active == 0

The key difference here is the function, you need getUserWindow(), not getCurrentWindow()


I was just able to make it work within the Selenium IDE.

Command: waitForCondition
Taret:   selenium.browserbot.getUserWindow().$.active == 0
Value:   30000


If this is in Firefox it could be wrapped in a XPCNativeWrapper. To get around that the "best practice" way to get the window is to called getUserWindow() which handles unwrapping object to become useable.

This is also assuming that jQuery isnt being loaded asynchronously.


The only way I could get this to work was to do the same in a C# test, instead of the Selenium HTML mode. In a C# test through the RC Server it works fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消