Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver3
0いいね 16回再生

Prompt : Selenium TestNG automation framework using ChatGPT #chatgpt #prompting #promptengineering

*Prompt:*

I'm looking to build a Selenium TestNG automation framework using the Page Object Model (POM) design pattern. The framework should automate testing of the "Elements" and "Forms" sections on the DemoQA website. The framework should be organized and structured for scalability, maintainability, and easy modification. Here are the requirements:

1. *Project Structure:*
`Pages` Folder: Contains all page classes.
`Tests` Folder: Contains all test classes.
`Utils` Folder: Contains utility classes like `PageCache`, `TestSetup`, and `Constants`.
`config.properties` File: Contains configuration data like the base URL.

2. *Key Classes:*
**`BasePage.java`**: A base class for all page objects with WebDriver initialization and common methods.
**`ElementsPage.java`**: Represents the "Elements" section with locators and actions.
**`FormsPage.java`**: Represents the "Forms" section with locators and actions.
**`PageCache.java`**: Manages page objects using `ThreadLocal` for thread safety and efficient reuse of page objects.
**`TestSetup.java`**: Manages setup and teardown of the WebDriver, loads the `config.properties` file, and initializes the browser session.
**`Constants.java`**: Stores constant values like timeouts.
**`config.properties`**: Configuration file for storing the base URL and other configurable parameters.

3. *Code Implementation:*
Provide code for each of the above classes, ensuring they are linked together correctly.
The `TestSetup` class should read the `BASE_URL` from the `config.properties` file.
The `ElementsPageTest.java` and `FormsPageTest.java` should be sample test classes to verify that the "Elements" and "Forms" sections can be accessed.

4. *Explanation:*
Include a step-by-step explanation of the entire framework, from the structure to how the classes interact with each other.
Explain concepts like `ThreadLocal`, POM, and how they are used in this framework.

5. *Optimization:*
Ensure the code is optimized by abstracting repetitive code into the `BasePage` class.
Provide any additional tips on how to maintain or extend the framework.

コメント