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

Executing commands directly on sections? #634

Open
drptbl opened this issue Sep 12, 2015 · 8 comments
Open

Executing commands directly on sections? #634

drptbl opened this issue Sep 12, 2015 · 8 comments

Comments

@drptbl
Copy link

drptbl commented Sep 12, 2015

Hello, I was wondering if that's even possible.

I want to execute a command directly on some section. For example - I want to .waitForElementVisible directly on section (not on elements). Is it even possible? I've tried a lot of combinations, for example:

browser.page.topMenu().section.loginBox.section.unauthenticated.waitForElementVisible('@loginTooltip', 10000)

So it looks like this: topMenu() is my pageObject file, then there is loginBox section containing -> unauthenticated section containing -> loginTooltip section. I want to .waitForElementVisible on the last one section. How to do this? I know I can combine my sections without limitations, but how to work on them later on?

Best regards,
drptbl.

@StephenDavidson
Copy link

I use an expectation with a cb in my project. Something like:

browser.page.topMenu().section.loginBox.section.unauthenticated.expect.section('@loginTooltip').to.be.visible.before(10000);

@drptbl
Copy link
Author

drptbl commented Sep 12, 2015

That's a good solution for assertions. Thank you!

I'm wondering - what about commands instead of assertions? Like .click? Is there any way to execute those directly on sections?

@sknopf
Copy link
Collaborator

sknopf commented Sep 13, 2015

Not currently but it's something we could look at adding.

A workaround would be something like:

var loginToolTipSelector = browser.page.topMenu().section.loginBox.section.unauthenticated.section.loginToolTip.selector;
browser.click(loginToolTipSelector);

You'll have to call useXpath/useCss directly if the locate strategy differs from the previous one.

@drptbl
Copy link
Author

drptbl commented Sep 13, 2015

This works excellent for now. Thank you 👍!

Adding this feature would make less code to maintain, still it does the job and I'm happy with this :).

@Ftelf
Copy link

Ftelf commented Aug 12, 2016

Hello,
About that.
var loginToolTipSelector = browser.page.topMenu().section.loginBox.section.unauthenticated.section.loginToolTip.selector;
I believe that this is not an option since you'll get only the leaf selector, not the whole construct. if the loginToolTip.selector is the same in other branch of xpath you'll get false positive. In that case the section construct does not have a sense and you can have just parent element instead.

But back to the original issue: " calling directly on section"

If I have a section which I want to use also the same way as a element, I'll add a container element into it:
elements: { container: { selector: '.', locateStrategy: 'xpath' },
Now I can use:
list.section.segmentationsContainer.expect.element('@container).to.be.present'

@drptbl
Copy link
Author

drptbl commented Aug 30, 2016

Waiting for this PR to be merged:
#1155
should do the job.

@mrmunch
Copy link

mrmunch commented May 30, 2017

@sknopf Do we still have to use this workaround?

@rodrigogs
Copy link

@sknopf Do we still have to use this workaround?

What would be the correct way for clicking a section element?

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

7 participants