私は、2つのレイヤーがあるPageObjectパターンに従って、Selenium Webdriverを使用して自動化フレームワークを開発中です。
- テストクラス (テスト仕様)
- PageObject クラス (テスト実装)
私のテスト クラスには、PageObject クラスのオブジェクトを作成し、実際に AUT とやり取りするこれらのクラスのメソッドを呼び出すTestNG 注釈メソッド ( 、 など) が含まれ@Test
ています。@BeforeTest
@AfterTest
テストにデータを渡す方法は、次を含めることです。
- アプリケーション内の要素のすべてのロケーター (css/xpath/class/id ロケーター)。
- 必要なすべてのテストデータ
プロパティ ファイル (例: testDataSet1.properties)。プロパティ ファイルを作成HashMap<String, String>
し、ハッシュマップからデータを読み取ってスクリプトで使用するすべてのページ オブジェクトにパラメーターとして渡します。テストクラスからテストデータをまったく渡していません。
What my problem is, I am not sure whether it is appropriate to read test-data in PageObjects. I get a feeling that this approach is very inflexible because I am tying test data to PageObjects instead of tying it to the tests. So when I need to perform data-driven tests / run the automation suite in multiple iterations, this will not work. Because, currently if I need to use different data each time I need to manually go and change the key specified in the hashmap which will fetch me a different value from the properties file.
Any suggestions?