P. 1
Selenium Documentation

Selenium Documentation

|Views: 1.836|Likes:
Publicado porraj_esh_0201

More info:

Published by: raj_esh_0201 on Mar 03, 2010
Direitos Autorais:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





All getFoo and isFoo methods on the Selenium prototype are added as accessors (storeFoo). For each
accessor there is an assertFoo, verifyFooa nd waitForFoo registered. An assert method can take up
to 2 parameters, which will be passed the second and third column values in the test. You can also
define your own assertions literally as simple “assert” methods, which will also auto-generate “verify”
and “waitFor” commands. Example: Add a valueRepeated assertion, that makes sure that the element


Selenium Documentation, Release 1.0

value consists of the supplied text repeated. The 2 commands that would be available in tests would be
assertValueRepeated and verifyValueRepeated.

Selenium.prototype.assertValueRepeated = function(locator, text) {
// All locator-strategies are automatically handled by "findElement"
var element = this.page().findElement(locator);

// Create the text to verify
var expectedValue = text + text;

// Get the actual element value
var actualValue = element.value;

// Make sure the actual value matches the expected
Assert.matches(expectedValue, actualValue);


9.3.1 Automatic availability of storeFoo, assertFoo, assertNotFoo, waitForFoo
and waitForNotFoo for every getFoo

All getFoo and isFoo methods on the Selenium prototype automatically result in the availability of store-
Foo, assertFoo, assertNotFoo, verifyFoo, verifyNotFoo, waitForFoo, and waitForNotFoo commands.
Example, if you add a getTextLength() method, the following commands will automati-
cally be available: storeTextLength, assertTextLength, assertNotTextLength,
verifyTextLength, verifyNotTextLength, waitForTextLength, and
waitForNotTextLength commands.

Selenium.prototype.getTextLength = function(locator, text) {
return this.getText(locator).length;


Also note that the assertValueRepeated method described above could have been implemented
using isValueRepeated, with the added benefit of also automatically getting assertNotValueRe-
peated, storeValueRepeated, waitForValueRepeated and waitForNotValueRepeated.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->