HOWDY!

I wrote my own assertElementOrder a few months back and today I finally updated to the newest version 0.5 of selenium (from 0.3).

So I moved my custom assertion into the user-extensions.js as instructed.  However it no longer works.

The code will best explain what I'm doing (error details below code):

SELENIUM SCRIPT:
<command name="assertElementPresent" target="//a[text()='Locked Topic']"/>
<command name="assertElementOrder" target="//a[text()='Sticky Topic']; //a[text()='Locked Topic'];"/>

USER-EXTENSIONS.JS
Selenium.prototype.assertElementOrder = function(locators) {
    var allElements = this.page().findAllElements();

    // split the locators into locators
    var locator = locators.split(";");

    for (i = 0; i < locator.length; i++) {
        // throws a can't find exception
        element = this.page().findElement(locator[i]);
        // assert this element is in the remaining allElements iteration
        var nextElement = null;
        var elementFound = false;

        while (!elementFound && (nextElement = allElements.iterateNext()) != null) {
            if (nextElement == element) {
                elementFound = true;
            }
        }
        if (!elementFound) {
            fail(locator[i] + " not in position " + (i + 1));
        }
    }
}

SELENIUM-BROWSERBOT.JS
PageBot.prototype.findAllElements = function() {
    // If the document doesn't support XPath, mod it with html-xpath.
    // This only works for IE.
    if (!this.currentDocument.evaluate) {
        addXPathSupport(this.currentDocument);
    }

    // If we still don't have XPath bail.
    // TODO implement subset of XPath for browsers without native support.
    if (!this.currentDocument.evaluate) {
        throw new Error("XPath not supported");
    }
    return this.currentDocument.evaluate("//*", this.currentDocument, null, 0, null);
}

ERROR:
The first command works great.

The second command displays:
Element //a[text()='Locked Topic'] not found
* notice it is the second element that is breaking
* notice that I don't display this error code it is coming from somewhere else
* and since the first line works it isn't the XPath that is broken

for those reason I conclude that something deeper within selenium has been changed

any ideas?

THANKS FOLKS

--
Jamo Smith
_______________________________________________
Selenium-devel mailing list
Selenium-devel@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-devel

Reply via email to