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

[Enhancement] Add findElementFromElement() and findElementsFromElement() commands #2875

Open
beatfactor opened this issue Aug 23, 2021 · 4 comments
Assignees

Comments

@beatfactor
Copy link
Member

We need more user friendly commands which perform the equivalent of elementIdElement() and elementsIdElement but work more like findElement() and findElements(), accepting the same type of arguments.

syntax findElementFromElement() (find single):

const element = await browser.findElementFromElement('form', 'input');
console.log('element', element.getId());
const element = await browser.findElementFromElement({selector: 'form', index: 0}, 'input');
console.log('element', element.getId());
const element = await browser.findElementFromElement(by.css('form'), 'input');
console.log('element', element.getId());
const formElement = element('form'); // or element(by.css('form'));
const element = await browser.findElementFromElement(formElement, 'input');
console.log('element', element.getId());

syntax findElementsFromElement() (find multiple):

const elements = await browser.findElementFromElement('form', 'input');
elements.forEach(element =>  console.log('element', element.getId()));
@MurzNN
Copy link

MurzNN commented Oct 14, 2024

I'm trying to implement exactly the same at least as a custom Nightwatch command, but faced a very strange issue #4273 - any ideas about why the issue happens and how to workaround it?

@MurzNN
Copy link

MurzNN commented Oct 14, 2024

@beatfactor, if you implemented this feature on your side or at least have some progress with it, could you please share your progress here? Thanks!

@beatfactor
Copy link
Member Author

Hey, if you're using v3, you can use the new element APIs for this: https://nightwatchjs.org/api/element/

@MurzNN
Copy link

MurzNN commented Oct 15, 2024

Hey, if you're using v3, you can use the new element APIs for this: https://nightwatchjs.org/api/element/

Thanks! With the element API all works well without the issue, even on Nightwatch v2! Missed this feature before.

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

3 participants