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的に,こうゆうのはどうやってテストするのが正しいのだろう?
Fitnesse Selenium Wrapper
顧客にこんなコード
|The user navigates to the URL|http://www.google.com| |The page has the title|Google| |The page has an element named|q| |The page has an element named|btnG| |The user Types|Cory Foy|in the field named|q| |The user clicks on the button named|btnG| |The user closes the browser|
を書かせたくて,Selenium-RCと連携するFitnessのFixtureを作ったよ.ってな話.
なるほど!!アイデアは悪くない.
でもTesting DSLと言われても英語だし,日本の顧客にテストコード書いてくれるような人は,そうはいるまい.
なんでLiFT同様,すごいけど実用に至らずダ.
TiffanyScreens
画面共有ソフト.プレゼンテーションとかに使うとよさげ.
マルチプラットフォームなのも良い.