2011年11月9日水曜日

Seleniumクラスの動作検証

以前

Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);

こんな感じでSeleniumクラスを生成すれば全てのSeleniumコマンドを実行出来ると書いたけど、間違いでした。


selenium-webdriver自体のソースの中身を見たところ、実装されているのはこのコマンドのみ(Selenium2.11現在)


addLocationStrategy
addSelection
allowNativeXpath
altKeyDown
altKeyUp
assignId
attachFile
captureScreenshotToString
click
clickAt
check
chooseCancelOnNextConfirmation
chooseOkOnNextConfirmation
close
createCookie
controlKeyDown
controlKeyUp
deleteAllVisibleCookies
deleteCookie
doubleClick
dragdrop
dragAndDrop
fireEvent
focus
getAlert
getAllButtons
getAllFields
getAllLinks
getAllWindowTitles
getAttribute
getAttributeFromAllWindows
getBodyText
getConfirmation
getCookie
getCookieByName
getElementHeight
getElementIndex
getElementPositionLeft
getElementPositionTop
getElementWidth
getEval
getExpression
getHtmlSource
getLocation
getSelectedId
getSelectedIds
getSelectedIndex
getSelectedIndexes
getSelectedLabel
getSelectedLabels
getSelectedValue
getSelectedValues
getSelectOptions
getSpeed
getTable
getText
getTitle
getValue
getXpathCount
goBack
highlight
isAlertPresent
isChecked
isConfirmationPresent
isCookiePresent
isEditable
isElementPresent
isOrdered
isSomethingSelected
isTextPresent
isVisible
keyDown
keyPress
keyUp
metaKeyDown
metaKeyUp
mouseOver
mouseOut
mouseDown
mouseDownAt
mouseMove
mouseMoveAt
mouseUp
mouseUpAt
open
openWindow
refresh
removeAllSelections
removeSelection
runScript
select
selectFrame
selectWindow
setBrowserLogLevel
setContext
setSpeed
setTimeout
shiftKeyDown
shiftKeyUp
submit
type
typeKeys
uncheck
useXpathLibrary
waitForCondition
waitForFrameToLoad
waitForPageToLoad
waitForPopUp
windowFocus
windowMaximize


用はmouseDownRightとかは実装していません。

あんまり使う機会無いと思うから、優先順位低いんだと思われる。

上記に引数を指定してコマンドを実行する。
検証した結果
"hogehoge"や"id=hogehoge"などで大丈夫だった。おそらく"name=hogehoge"とかでも大丈夫。検証してないけど。
多分SeleniumIDEで記録した「値」の部分をそのまま引数で指定してあげればいける。
”value=”や"link="などロケーション種別が存在しないときはidもしくはnameとして認識しているのだと思われる。
そこら辺はリファレンス通りの仕様。

2011/12/22追記
なんと上記コマンドはIE8上では動作しない。
javascriptを実行することによって代替機能を実装するか、webdriverの機能を使って実装しなおす必要がある。

残念すぎる。

2011/12/28追記
実行出来ないのはfucusやmauseOverなど一部のみ。waitForPopup等は実行出来る。よかた。
でも安定しない。結局何もかもwebdriverベースで書いたほうがよさそうだ。

0 件のコメント:

コメントを投稿