MarkusBernhardt / robotframework-selenium2library-java

Java port of the Selenium 2 (WebDriver) Python library for Robot Framework
Apache License 2.0
46 stars 48 forks source link

NullPointerException @ SessionIdAliasWebDriverTuple.alias #23

Closed zagasilva closed 11 years ago

zagasilva commented 11 years ago

The NullPointerException is being thrown if you use Open Browser without an alias. In the Close Browser function code you're not considering the null alias option. I've added that if and my tests are working now.

Please see the following code:

public void close() {
    if (currentSessionIdAliasWebDriverTuple != null) {
        // Close the webdriver and remove it fomr all stores
        currentSessionIdAliasWebDriverTuple.webDriver.quit();
        tupleBySessionId.remove(currentSessionIdAliasWebDriverTuple.id);
        if(currentSessionIdAliasWebDriverTuple.alias != null) {
            tupleByAlias.remove(currentSessionIdAliasWebDriverTuple.alias);
        }
        openSessionIds.remove(currentSessionIdAliasWebDriverTuple.id);
        closedSessionIds.push(currentSessionIdAliasWebDriverTuple.id);

        // Set the last opened webdriver as current webdriver
        if (openSessionIds.size() != 0) {
            currentSessionIdAliasWebDriverTuple = tupleBySessionId
                    .get(openSessionIds.pop());
        } else {
            currentSessionIdAliasWebDriverTuple = null;
        }
    }
}

Best Regards

MarkusBernhardt commented 11 years ago

Ups. Thank you very much for that catch!

zagasilva commented 11 years ago

Np :) Please fix it and reupload it to Maven because i'm using a local build to run my tests. You may need to update the README with the new links for that build too (the jar and jar without dependencies links). Best Regards

MarkusBernhardt commented 11 years ago

I'm at the moment on a high speed train to Amsterdam. So I don't have the bandwidth to push out a release. Will do it tomorrow.

MarkusBernhardt commented 11 years ago

Done. Release is out.