SeleniumでAttributeの存在チェック

昔のSelenium(0.3系)の頃は,こんな感じで「Attributeが無い」テストができたんだけど,

+-----------------+------------+------+
| assertAttribute | test@class | null |
+-----------------+------------+------+

0.7.1にしたら"Could not find element attribute:xxx"って怒られるようになった.:-(
仕方ないんで,selenium-api.jsにえげつないパッチを当ててしのぐ.

Selenium.prototype.getAttribute = function(attributeLocator) {
  /**
   * Gets the value of an element attribute.
   *
   * Beware of http://jira.openqa.org/browse/SEL-280, which will lead some event handlers to
   * get null event arguments.  Read the bug for more details, including a workaround.
   *
   * @param attributeLocator an element locator followed by an @ sign and then the name of the attribute, e.g. "foo@bar"
   * @return string the value of the specified attribute
   */
  var result = this.page().findAttribute(attributeLocator);
  if (result == null) {
//     throw new SeleniumError("Could not find element attribute: " + attributeLocator);
    return null;    // :-D
  }
  return result;
};

#ズルいとか言わない.


そういえば,assertAttribute/assertNotAttribute(verifyもね)は,「Attritubeがある」ってのが前提で,その値をどうこうするのに使えるけど,「Attributeそのもの」の有無には使えないのだな.
Selenium的に,こうゆうのはどうやってテストするのが正しいのだろう?