Skip to content

Commit 2b1d937

Browse files
committed
user_extention.js - Add waitAndClick and WaitAndType, to support ajax request wich update dom
0 parents  commit 2b1d937

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Diff for: user_extention.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Selenium.prototype.doWaitAndClick = function(locator, timeout) {
2+
/**
3+
* First, Wait to find the element (specified by locator).
4+
* Finally, clicks on it (a link, button, checkbox or radio button)
5+
*
6+
* @param locator an <a href="#locators">element locator</a>
7+
* @param timeout Optional - a timeout in milliseconds, after which the action will return with an error.
8+
* If this value is not specified, the default Selenium
9+
* timeout will be used. See the setTimeout() command.
10+
*/
11+
12+
if (! timeout) {
13+
timeout = this.defaultTimeout;
14+
}
15+
16+
return Selenium.decorateFunctionWithTimeout(function() {
17+
find = selenium.isElementPresent(locator);
18+
if (find) {
19+
LOG.info(location + ' has been found...');
20+
selenium.doClick(locator);
21+
LOG.info(location + ' has been clicked...');
22+
}
23+
return find;
24+
}, timeout);
25+
26+
}
27+
28+
Selenium.prototype.doWaitAndType = function(locator, text) {
29+
/**
30+
* First, Wait to find the element (specified by locator).
31+
* Finally, type the text inside the element found
32+
*
33+
* @param locator an <a href="#locators">element locator</a>
34+
* @param text text to type in the element identified by locator.
35+
*/
36+
return Selenium.decorateFunctionWithTimeout(function() {
37+
find = selenium.isElementPresent(locator);
38+
if (find) {
39+
LOG.info(location + ' has been found...');
40+
selenium.doType(locator, text);
41+
LOG.info(text + ' has been typed...');
42+
}
43+
return find;
44+
}, this.defaultTimeout);
45+
}
46+
47+
// Selenium.prototype.doWaitingReqs = function(timeout) {
48+
// if (! timeout) {
49+
// timeout = this.defaultTimeout;
50+
// }
51+
// return Selenium.decorateFunctionWithTimeout(function() {
52+
// var testWindow = selenium.browserbot.getCurrentWindow();
53+
// if (testWindow.jQuery.active == 0) {
54+
// return true;
55+
// }
56+
// return false;
57+
// }, timeout);
58+
// }

0 commit comments

Comments
 (0)