I'm immersing myself in DDD and have a question regarding what belongs to the domain, and what is an infrastructure concern.
A simplified example to describe the domain:
One of the contexts in the App is regarding convenience functionality that allows users to examine web pages for certain information. i.e..
"A user wants to examine a web page and determine whether the phrase "lorem ipsum" appears and in what location."
We will use Selenium as the underlying technology for matching the phrase.
Before diving into DDD I would have created a Class like below (Python below but language shouldn't matter):
class Page:
def __init__(self, url, environment, driver):
self.environment = environment
self.url = url
self.driver = driver // Selenium Driver
def contains_phrase(self, phrase):
self.driver.get(self.environment.url + self.url_suffix) // Selenium Command
...
This entity is now dependent on selenium, and is no longer a pure object (POCO, POJO etc). This doesn't feel correct to me in DDD.
My understanding is that the the selenium expressions also don't belong in the Application Service layer, as this would bloat the class / method and the service layer should ideally be thin.
Does this then belong in the Infrastructure layer? Much like a Repository with persistence code living there. Something like:
class PageAutomator:
...
def does_page_contain_phrase(self, page, phrase):
self.driver.get(self.environment.url + self.url_suffix) // Selenium Command
Does this sound like the correct direction? And if so?:
This means the Page entity is starting to tend towards an anaemic model, and is becoming a simple DTO. If so is this entity even necessary any more?
Is it acceptable for the Application Service layer to call the Infrastructure layer directly and perform some action (to perform a use case) without the involvement of any entities (and hence the domain) at all? Even if taking more of a Transaction Script approach, my understanding is the Selenium functionality still shouldn't live in the domain?
Or (and I'm new to DDD) I'm complete way off base, in which case any advice or suggestions are very welcome.
Thanks
Searching for a string inside HTML is not business logic so domain driven design should not apply here.
A DTO or a class without behavior representing the page makes sense here.
The "search service" would be an infrastructure concern if there is a need for an abstraction over the Selenium specific implementation or re-usability across applications. If there is no need for that, it would be an application specific service/utility.