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

PartialPageObjects should be scope providing #16

Open
Amiron49 opened this issue Apr 14, 2015 · 1 comment
Open

PartialPageObjects should be scope providing #16

Amiron49 opened this issue Apr 14, 2015 · 1 comment

Comments

@Amiron49
Copy link

If I define a PartialPageObject I would expect it to be a reusable component so that you do not have to re-define it on every single page and that you do not need to rely on IDs to select sub components of it.

For example consider a kind of message box that has a button inside of it which is used multiple times on different pages/same page but each with a different ID, possibly generated from a template like this

<div id="{{ID}}">
 <button class="MyDialogButton">Ok</button>
<div>

PageObject

class Dialog: BasePageObject
{
 [Locate(How = How.CssSelector, Using = "MyDialogButton")]
 public Button Ok { get; set; }
}

Now on the page which uses 2 of them I would want to define it like this WITHOUT relying on extra IDs to access the Buttons
PageObject

class myPage: BasePageObject
{
 [PartialPageObject]
 [Locate(How = How.Id, Using = "Dialog1")]
 public Dialog Dialog1 { get; set; }

 [PartialPageObject]
 [Locate(How = How.Id, Using = "Dialog2")]
 public Dialog Dialog2 { get; set; }
}
class PageTest : AbstractTestcase
{
 ...
 myPageInstance.Button1.Ok.Click();
}

Considering how every single Locator is using an Xpath anyway a simple way would be to concat the Xpaths.

@florianwittmann
Copy link
Contributor

Good request for sure.
If no Locate for a PartialPageObject and thus no scope is provided, it should keep the current behaviour and search the elements globally.

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

No branches or pull requests

2 participants