Skip to content

Faster, full unti-flakyness, parallelisation-friendly, customizable per elements

Pre-release
Pre-release
Compare
Choose a tag to compare
@yashaka yashaka released this 29 Apr 20:15

SUMMARY:

  • upgraded waiting of commands, error messages, thread local configuration, etc. (see CHANGELOG for more details)
    • it should be
      • faster,
      • more stable/less-flaky (with implicit waiting till no overlay-style pre-loaders)
      • more friendly to parallelisation in context of configuration,
      • more customizable on elements level (not just global)

Migrating from 1.0.0-alpha03 guide

  • upgrade and check your build
    • refactor your custom conditions:
      • if you have implemented your own custom conditions by extending e.g. Condition<SeleneElement>
        • you will get a compilation error – to fix it:
          • change base class from Condition<SeleneElement> to DescribedCondition<SeleneElement>
          • remove public override string Explain() and leave public override string ToString() instead
          • if you use anywehere in your code an Apply method on condition of type Condition<TEntity>
            • you will get an obsolete warning
              • refactor your code to use Invoke method, taking into account that
                • anytime Apply throws exception - Invoke also throws exception
                • anytime Apply returns false - Invoke throws exception
                • anytime Apply returns true - Invoke just passes (it's of void type)
    • refactor obsolete things, like:
      • Configuration.WebDriver => Configuration.Driver
      • S("#element").ShouldNot(Be.*) to S("#element").Should(Be.Not.*)
      • S("#element").ShouldNot(yourCustomCondition) to S("#element").Should(yourCustomCondition.Not)
      • etc
  • take into account, that some "internal" methods of 1.0.0-alpha05 were made public for easiser experimental testing in prod:),
    but still considered as internal, that might change in future
    such methods are named with _ prefix,
    following kind of Python lang style of "still publically accessible private" methods:)
    use such methods on your own risk, take into account that they might be marked as obsolete in future
    yet, they will be eather renamed or made completely internal till stable 1.0 release;)
    read CHANGELOG for more details.

Details

  • added Be.Not.* and Have.No.* as entry points to "negated conditions"
  • .ShouldNot is obsolete now, use .Should(Be.Not.*) or .Should(Have.No.*) instead
  • added Condition#Not property, Condition#Or(condition), Condition#And(condition)
    • added condition-builder classes, yet marked as internal
      • Not<TEntity> : Condition<TEntity>
      • Or<TEntity> : Condition<TEntity>
      • And<TEntity> : Condition<TEntity>
      • yet they might be renamed in future... to something like NotCondition, OrConditioin, AndCondition
      • let's finalize the naming in #53
  • added SeleneElement extensions
    • .JsScrollIntoView()
    • .JsClick(centerXOffset=0, centerYOffset=0)
      • proper tests coverage is yet needed
      • the same can be achieved through (can be handy when storing element in var)
        element.With(clickByJs: true).Click()
    • .JsSetValue(value)
      • the same can be achieved through
        element.With(setValueByJs: true).SetValue(value)
    • .JsType(value)
      • the same can be achieved through
        element.With(typeByJs: true).Type(value)
  • made Configuration.* ThreadLocal
  • added SeleneElement methods:
    • WaitUntil(Condition) – like Should, but returns false on failure
    • Matching(Condition) - the predicate, like WaitUntil but without waiting
    • With([driver], [timeout], [pollDuringWaits], [setValueByJs], [typeByJs], [clickByJs]) - to override corresponding selene setting from Configuration
      • usage: element.With(timeout: 2.0)
    • _With_(_SeleneSettings_) option to fully disconnect element config from shared Configuration
      • underscores mean that method signature might change...
      • usage: element._With_(Configuration.New(timeout: 2.0))
  • added SeleneCollection methods:
    • WaitUntil(Condition) – like Should, but returns false on failure
    • Matching(Condition) - the predicate, like WaitUntil but without waiting
    • With([driver], [timeout], [pollDuringWaits], [setValueByJs], [typeByJs], [clickByJs]) - to override corresponding selene setting from Configuration
    • _With_(_SeleneSettings_) option to fully disconnect element config from shared Configuration
      • underscores mean that method signature might change...
      • usage: elements._With_(Configuration.New(timeout: 2.0))
  • added SeleneDriver methods:
    • WaitUntil(Condition) – like Should, but returns false on failure
    • Matching(Condition) - the predicate, like WaitUntil but without waiting
    • With([driver], [timeout], [pollDuringWaits], [setValueByJs], [typeByJs], [clickByJs]) - to override corresponding selene setting from Configuration
    • _With_(_SeleneSettings_) option to fully disconnect element config from shared Configuration
      • underscores mean that method signature might change...
      • usage: elements._With_(Configuration.New(timeout: 2.0))
  • tuned selene elements representation in error messages
    • now code like SS(".parent").FilterBy(Be.Visible)[0].SS(".child").FindBy(Have.CssClass("special")).S("./following-sibling::*")
    • renders to: Browser.All(.parent).By(Visible)[0].All(.child).FirstBy(has CSS class 'special').Element(./following-sibling::*)
  • improved waiting (waits not just for visibility but till "being passed") at SeleneElement's:
    • (... wait till visible and not overlapped)
      • Click()
      • Hover()
      • DoubleClick()
      • Submit()
      • Clear()
      • SetValue(keys)
      • Type(keys)
      • PressEnter()
      • PressEscape()
      • PressTab()
    • (... wait till visible for all but input[type=file])
      • SendKeys(keys)
  • upgraded waiting to new engine in asserts (.Should(condition)) of
    • SeleneElement
    • SeleneCollection
  • Deprecated (Marked as Obsolete)
    • Configuration.WebDriver (use Configuration.Driver instead)
      • it also becomes a recommended wa
        • to set driver: Configuration.Driver = myDriverInstance
          • over Selene.SetWebDriver(myDriverInstance)
            • that might be deprecated in future
        • also take into account that in frameworks like NUnit3,
          when you tear down driver in OneTimeTearDown (that will be executed after all test methods)
          ensure you do this by calling Quit on your own instance like myDriverInstance.Quit()
          DON'T do it like Configuration.Driver.Quit() or Selene.GetWebDriver().Quit()
          cause this will lead in memory leaked driver, this is NUnit thing, not NSelene:)
          (you still can do the latter in TearDown method that will be executed after each test method)
  • potential breaking changes:
    • Switched to System.TimeoutException in some waits (instead of WebDriverTimeoutException)