tnypxl / BasinFramework

An opinionated browser test framework built around Selenium WebDriver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convention-based loading of pages to sites

chaganiu opened this issue · comments

I'd like to get an opinion on loading pages to sites based on convetion.

If we were to enforce a directory structure (and namespace) like this:

- PageObjects
  - SiteName
    - PageName

and a config structure like this:

{
  "sites": {
    "siteName": {
      "pageName": "https://url.of.page.com"
    }
  }
}

we could then rely on the fully qualified namespace PageObjects.SiteName.PageName to add pages to a site and also look up the URLs for the site.

@chaganiu

I like it. When BasinEnv.SetConfig() is called, I could check the existence of page object class files and throw a useful error when they don't exist.

My only question is, should pageName only be a url or should it be an object allowing other page-level configuration in addition to the url?

So for example:

{
  "sites": {
    "siteName": {
      "pageName": {
        "url": "https://url.of.page.com"
        ...
        ...
      }
    }
  }
}

should it be an object allowing other page-level configuration in addition to the url?

yea that works.

as far as SetConfig how do you feel about using the pattern that appsettings.json uses in dotnet core? so config file names would be required to be in this format:

appsettings.json <-- main file
appsettings.qa.json <-- overrides for the qa env.

this way merging of config files into one IConfiguration object would be pretty simple.

var config = new ConfigurationBuilder()
  .SetBasePath(Root.Path.Of.Application)
  .AddJsonFile("appsettings.json")
  .AddJsonFile($"appsettings.{env}.json")
  .AddEnvironmentVariables()
  .Build();