-
-
Notifications
You must be signed in to change notification settings - Fork 17
Refactor element handling and browser interaction #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Replaced direct XPath-based element retrieval with a new `GetElement` method, supporting both `By` selectors and `Func<HtmlDocument, HtmlNode?>` delegates. Updated `Click` and `Input` methods to accept `IWebElement` directly, reducing redundancy and improving maintainability. Removed deprecated `WaitPageLoaded` and `WaitPageChanged` methods in favor of more generic `Wait` methods. Enhanced error handling with detailed messages for `WebDriverTimeoutException`. Updated the `Retry` class to include more descriptive timeout errors. Refactored all commands to use the new `GetElement` method and streamlined interaction logic. Removed redundant code and unused methods, improving readability and maintainability. Updated the `IChromeBrowser` interface to reflect these changes. Performed general code cleanup, including removing unused variables, redundant comments, and unnecessary method calls.
|
Version of this build is 2.12.79 |
- Added `[CallerArgumentExpression]` to `Wait` and `GetElement` methods for improved error reporting and debugging. - Updated `Wait` in `ChromeBrowser.cs` to include better error handling and context in timeout exceptions. - Modified `Click` to include a `Wait` call for ensuring specific conditions (e.g., visibility of the `logo` element). - Added a new `GetElement` overload in `IChromeBrowser.cs` supporting `By` locators with `[CallerArgumentExpression]`. - Updated `Wait` signature in `IChromeBrowser.cs` to align with the implementation in `ChromeBrowser.cs`. - Introduced `IDelayService` in `LoginTask.cs` to add delays for smoother execution during the login process. - Improved maintainability and reliability across the codebase by enhancing error handling and debugging capabilities.
Introduced a reusable `WaitPageChanged` method in `ChromeBrowser.cs` and `IChromeBrowser.cs` to handle URL changes and ensure pages are fully loaded. Updated various commands (`LoginCommand.cs`, `HandleUpgradeCommand.cs`, `ToBuildingByLocationCommand.cs`, `ToDorfCommand.cs`) to use this method after navigation actions. Removed redundant `Wait` logic from the `Click` method in `ChromeBrowser.cs`, consolidating it into `WaitPageChanged` for better modularity. Enhanced error handling in `WaitPageChanged` to provide detailed messages for failures.
|
Version of this build is 2.12.80 |
Refactored the `BuildingsModified` method to improve readability by reordering early exit checks and command executions. In the `JobsModified` method, moved `_taskManager.AddOrUpdate` for `UpgradeBuildingTask.Task` to the beginning of the method to ensure proper task handling before other operations. Removed redundant `_taskManager.AddOrUpdate` call at the end of `JobsModified` to eliminate duplication and improve clarity.
|
Version of this build is 2.12.81 |
Simplified the `Wait` method call by condensing the lambda expression into a single line for better readability. Enhanced the error message in the `if (result.IsFailed)` block to include the `CurrentUrl` property, providing additional context for debugging when the URL change wait fails.
|
Version of this build is 2.12.82 |
|
Version of this build is 2.12.83 |
asynchronous `GetElement` operation with a document parser (`TrainTroopParser.GetTrainButton`) and a cancellation token.
|
Version of this build is 2.12.84 |
Replaced the old `TrainTroopParser.GetTrainButton` logic with a more robust approach using `browser.GetElement` and a lambda function.
Enhanced error messages across the codebase for better clarity. Refactored the `Retry` class to simplify and standardize error handling using a new `Retry.Error` property. Introduced the `WithError` method for chaining additional error context. Improved logging to provide more context during execution, including adventure details and specific failure points. Simplified XPath handling by using `nodeGenerator` functions for better readability. Updated tab index validation logic in `SwitchTabCommand.cs` to ensure accurate error reporting. Refactored exception handling in `ChromeBrowser` to use the new `Retry.Error` mechanism. Removed redundant error-handling methods and standardized error reporting with the `Result.Fail(errors).WithError(...)` pattern. Made namespace-specific changes to ensure consistency in error handling and logging. Improved debugging support and code readability by reducing redundancy and adding detailed error messages. Added additional wait logic to enhance automation reliability.
Refactored the `Skip` class to replace static error instances with a generic `Skip.Error` that supports dynamic error messages via the `WithError` method. Updated all references to use the new approach, enabling more descriptive and context-specific error handling. Removed redundant static `Skip` error instances to improve maintainability and reduce code duplication.
Refactored the error handling mechanism across the codebase to use `WithError` and `WithErrors` methods for detailed and extensible error messages. - Replaced specific `Stop` error methods with a generic `Stop.Error` instance, allowing customization via `WithError`. - Made `Stop` constructor private to enforce the use of `Error`. - Updated `Skip` to include a default message and support `WithErrors`. - Replaced hardcoded error messages in various files with the new `WithError` and `WithErrors` methods for better clarity. - Removed redundant error methods like `JobNotAvailable` in `UpgradeBuildingError`. - Improved error propagation in `NPCTask` and `UpgradeBuildingTask`. These changes improve code maintainability and ensure consistent, user-friendly error messages throughout the application.
|
Version of this build is 2.12.85 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Yes, I use AI to generate the commit message, but I doubt it can fix the problem itself