Skip to content
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

New feature proposal: scrape page at test run-time from Selenium browser for element with id, name, or class corresponding to feature name? #104

Open
mattq314 opened this issue Mar 29, 2016 · 1 comment

Comments

@mattq314
Copy link

mattq314 commented Mar 29, 2016

Hi,

I'd like to propose a new feature for the SpecBind library. A co-worker was showing us how to use SpecBind (with Selenium) the other day, and I noticed that it is very close conceptually to allowing devs and testers to just configure the URL's under test and have SpecBind attempt a best match between elements mentioned in features and elements on the page in the Selenium browser object. That best match could be based on id, name, or class. If relying on name or class (for example) and multiple elements on the page have the same, a run-time exception could be thrown so the dev can disambiguate by changing an element id or a feature name (or both).

Example of desired result:

<pages>
    <add url="ProjectList.aspx"/>
    <add url="BudgetList.aspx"/>
</pages>

It seems like this configuration plus the feature tests could be enough test coding without defining/decorating a thin page model.

As an attempt to prove the concept for this proposal, I forked the SpecBind code and modified PageMapper.Initialize to use reflection to build (and cache) a page type, named like the name given in the configured URL. It allows a feature file to run against a correspondingly named page URL from the configuration.

I've tried modifying the SeleniumBrowser class to scrape the page that's currently loaded in the SeleniumBrowser object and dynamically add corresponding properties to the page type (and replace the page type in cache). However, even dynamically decorating these properties as LocatorElement's seems to not add them in time (or in the right place?) to be matched by the properties referenced in the feature file.

Can anyone give some recommendations on where/how I should make a change that will dynamically add these properties such that the property can match to the one referenced from the feature step (ideally only on the feature step where the property is referenced)?

Thanks,
Matt

@mattq314
Copy link
Author

Hi, can anyone provide pointers for the question above?

Thanks for any help,
Matt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant