次のパターンを使用して、Selenium webdriver を使用した単一ページ webapp 用のフレームワークを Java で開発しています: PageObject、SlowLoadableComponent (責任の連鎖)、PageFactory、HaveExpectedControls (各ページは、含まれている必要がある要素を認識し、.getExpectedControls を介してそれらを返します)
だから私は自分のページを次のように作成して使用します:
LoginPage loginPage = new LoginPage(driver, "http://mywebapp.com");
mainPage MainPage = new MainPage(driver, loginPage, "password");
mainPage.get(); //this method checks whether page .isLoaded(), if not - calls its .load() method and finally assert it .isLoaded()
for (WebElement element: mainPage.getExpectedControls()) {
assertTrue(element.isDisplayed);
}
私の現在の目標は、ユーザーが Web アプリケーションを閲覧しているときに実行できるすべての「パス」をテストすることです。
webapp階層の「より深い」ページに到達するまではすべて簡単でした...
マイページは次のように表すことができます
------------
|Login Page|
------------
->
|------------------------------
|LogoutLink
|---------------------------------
|mode: _ standart _ expert| __________________
|-------------------------| |SystemSettingsTab1|SystemSettingsTab2|SystemSettingsTab3
|*MainPage menu item | | ----------------------------------------
|*SomeOther menu item | | |
|... | | |
|*System menu item >->
|** Settings sub item >->
|... | |
|** OneMore sub item | |
さらに説明するための「ルール」を次に示します。
First you get Login Page
Then (if loged in) you allways get 'MainPage menu item' (and 'standard' mode checked)
You allways see (so can click only what you see):
- only that sub-menu-items that are inside 'current' menu item page
- only that sub-menu-items-tabs that are:
- inside current sub-menu-item
- is correspondent to the current mode ('expert' mode allows more tabs)
Once clicked on any 'item' you allways get its first 'child item'
Then whatever you do you can:
- logout
- switch to any 'item' which you can see (check correspondent section above):
i.e.:
- switch to any other menu-item page by clicking on it
- switch to any of sub-menu-items of the current menu-item:
there is a special case for 'the first sub-menu-item':
you can get it by:
- clicking on its sub-menu-item link
- on its parent menu-item
- switch to any of sub-menu-item-tabs of current sub-menu-item
there is a special case for 'the first sub-menu-item-tab':
you can get it by:
- clicking on its sub-menu-item-tab link
- on its parent sub-menu-item
- on its parent menu-item
質問: 設計方法:
すべてのページのクラス階層?
テストでそれらをサーフィンする方法は?(特に、いくつかのリンクからページを取得できる特別なケースを含む)