protractor icon indicating copy to clipboard operation
protractor copied to clipboard

No element found using locator error

Open Saurabh06 opened this issue 10 years ago • 3 comments

I am trying to click a button but i get all the time that error •Failed: No element found using locator: By.xpath("//h3[contains(text(),'Deluxe\xA0Twin')]/parent::div/parent::div/preceding-sibling::div/div/button[contains(text(),'Book')]")

But when i try it manually then it showing that element is present on that page??

Saurabh06 avatar Feb 18 '16 06:02 Saurabh06

Hi there!

Your question is better suited for StackOverflow or Gitter. Please ask a question there with the 'protractor' tag or post in the Gitter Channel to get help.

From the the getting help section of the README:

Please ask usage and debugging questions on StackOverflow (use the "protractor" tag) or in the Angular discussion group. (Please do not ask support questions here on Github.)

Thanks!

NickTomlin avatar Feb 18 '16 14:02 NickTomlin

Hi Nick,

I have asked around 3-4 questions over Gitter and StackOverflow regarding protractor, but i haven't got any answer for any of my questions.That's why i have asked on Github.

Thanks, Saurabh

On Thu, Feb 18, 2016 at 8:13 PM, Nick Tomlin [email protected] wrote:

Hi there!

Your question is better suited for StackOverflow or Gitter. Please ask a question there with the 'protractor' tag http://stackoverflow.com/questions/ask?tags=protractor or post in the Gitter Channel https://gitter.im/angular/protractor to get help.

From the the getting help https://github.com/angular/protractor#getting-help section of the README:

Please ask usage and debugging questions on StackOverflow (use the "protractor" tag) or in the Angular discussion group. (Please do not ask support questions here on Github.)

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/angular/protractor/issues/2955#issuecomment-185750474 .

Saurabh06 avatar Feb 18 '16 15:02 Saurabh06

Hi,

Hi,

Using Xpath selectors is not a better choice as it slows down the element finding mechanism.

I have designed a plugin to address this specific issues: protractor-css-booster

The plugin provides some handly locators to find out siblings in a better way and most importantly with CSS selector.

using this plugin, you can directly use:

var elem = element(by.cssContainingText('a','link text')).element(by.followingSibling('img'));

You can always checkout the other handy methods available here...

Now, you can find web elements such as:

  1. Finding Grand Parent Element
  2. Finding Parent Element
  3. Finding Next Sibling
  4. Finding Previous Sibling
  5. Finding any Following Sibling
  6. Finding First Child Element
  7. Finding Last Child Element

And, guess what, everything you can find using 💥 CSS Selectors 💥

Hope, it will help you...

abhinaba-ghosh avatar Oct 22 '19 18:10 abhinaba-ghosh