Extend an Action

From STIQ

Jump to: navigation, search

All doFoo methods on the Selenium prototype are added as actions. For each action foo there is also an action fooAndWait registered. An action method can take up to two parameters, which will be passed the second and third column values in the test.

Example: Add a typeRepeated action to Selenium, which types the text twice into a text box.


	Selenium.prototype.doTypeRepeated = function(locator, text) {
	    // All locator-strategies are automatically handled by "findElement"
	    var element = this.page().findElement(locator);
	
	    // Create the text to type
	    var valueToType = text + text;
	
	    // Replace the element text with the new text
	    this.page().replaceText(element, valueToType);
	};
Personal tools
Noteworthy