Skip to content

Externally useful attributes should be declared public and documented. #882

Closed

Description

@pekkaklarck

Old Selenium2Library has several attributes that are useful externally from custom libraries and extensions:

_run_on_failure_keyword
_speed_in_secs
_timeout_in_secs
_implicit_wait_in_secs
_current_browser()

We should indicate that using these externally is OK by removing the leading underscore. The current WebDriver instance should also be accessible as a normal attribute (i.e. without calling a method like current_browser()) and we should name the attribute webdriver to make it explicit what it actually is. I would also remove unnecessary _in_secs postfixes. In other words, I would like to have these attributes instead:

run_on_failure_keyword
speed
timeout
implicit_wait
webdriver

Renaming these attributes is obviously a backwards incompatible change. We should thus add propertys that enable the old functionality but emit deprecation warnings. These propertys can then be removed in 3.1 or later.


UPDATES:

  1. We used browser attribute instead of webdriver until 3.0 RC 1.

  2. In 3.0 RC 1 we added also methods find_element and find_elements directly to the library itself. These methods form the recommended public API to find elements for external tools.

Activity

  1. added this to the v3.0.0 milestone on Sep 2, 2017
  2. pekkaklarck commented on Sep 2, 2017

    @pekkaklarck
    MemberAuthor

    This is mostly fixed if #884 is merged. The remaining decisions to make are:

    • Should deprecated attributes be unit tested somehow? Shouldn't be too hard, but adding tests for features that are going to be removed pretty soon feels a bit like waste.

    • What do to with _browsers?

  3. added a commit that references this issue on Sep 4, 2017
  4. aaltat commented on Sep 6, 2017

    @aaltat
    Contributor
    1. I think that it is waste too, lets not do unit test for those.
    2. Is the cache for drivers. There already are public API to register driver, get the current driver and switch between drivers and close driver. With those API it might be better to leave it private.
  5. pekkaklarck commented on Sep 9, 2017

    @pekkaklarck
    MemberAuthor

    If we aren't going to add more tests and we'll keep _browsers as-is, isn't this issue done?

  6. aaltat commented on Sep 10, 2017

    @aaltat
    Contributor

    Yes it's. Closing

  7. 6 remaining items

  8. boakley commented on Oct 21, 2017

    @boakley
    Contributor

    I agree with @aaltat - driver and browser both seem better than webdriver. I would prefer you stick with browser since the code is already in release candidate status and public interfaces shouldn‘t be changing.

  9. pekkaklarck commented on Oct 21, 2017

    @pekkaklarck
    MemberAuthor

    We aren't in RC yet. In earlier versions this attribute was _browser and thus it wasn't really public. The reason I'd call it webdriver is that it is an instance of WebDriver and tbe idea is that external users can use its functionality as needed. That name would make the situation explicit even without much documentation.

  10. boakley commented on Oct 21, 2017

    @boakley
    Contributor
  11. aaltat commented on Oct 23, 2017

    @aaltat
    Contributor

    Adding sphinx style definitions helps users of the methods and IDE's to provide auto completions for arguments and return values.

    • Change ContextAware class param to param and typeto better support Sublime Anaconda plugin
    • Add find_elements to contain similar type of definitions as find_element
  12. aaltat commented on Oct 23, 2017

    @aaltat
    Contributor

    I prefer using driver, because that is defacto way of referring to the WebDriver instance.

    I agree that making changes this late in release pipeline is causing problems for the end users who have extended SL with their own libraries. I am one of those users, too. But I also agree that the old public API, or lack of it, is also a big problem. I hope that we can now implement a better public API which allows extending the library in more easier and cleaner way.

  13. aaltat commented on Oct 23, 2017

    @aaltat
    Contributor

    Did forget to say that the plan is to keep some of the old non public API interface in place, to ease the transition from S2L 1.8.0 to SL 3.0.0. If I recall correctly, @boakley requirements for the old API are pretty much the same as mine. But I know that if users have used ElementFinder, TableElementFinder or some other internal functionality, the code is not anymore backwards compatible.

  14. changed the title [-]Externally useful attributes should be declared public and not start with an underscore[/-] [+]Externally useful attributes should be declared public and documented.[/+] on Oct 31, 2017
  15. aaltat commented on Oct 31, 2017

    @aaltat
    Contributor

    Document public properties and find_elements with sphinx documentation. At least document the types and if method document return types.

  16. aaltat commented on Nov 14, 2017

    @aaltat
    Contributor

    The sphinx documentation is done in #994

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions