1

I am searching for something specific, from a dropdown and want to capture the error message when no results are found. The message to be displayed from the toaster is "No Records Found"

  • Then you need to write the code and ask us what we think. We do not just write code answers to code questions. That usually means you are interviewing or seeking free consulting, however neither of those is a valid reason on the site. The question will likely be closed by others shortly – Michael Durrant Jun 25 '18 at 11:16
  • @Michael Durrant-I have added the code I was using to capture the message, however as it was not working for me, i did not provide it earlier. I would be eagerly expecting for your answer now, as I have provided it – ravenclaw_93 Jun 25 '18 at 16:01
  • 1
    Please a tag indicating the language you are using and also add the code as actual text formatting using the markdown format (basically single or triple backtics). Also indicate if this is Angular. Also this is not for "me" to fix once done, it is for anyone in our community to help you (including me). By following these guidelines you will greatly increase the chance of help for your issue. – Michael Durrant Jun 25 '18 at 16:34
0

Try using the class name

String text = driver.findElement(By.className("toast-title")).getText();

or the XPath

String text = driver.findElement(By.xpath("//div[@ng-class=‘config.title’])).getText();

I think this is an angular application so you can try ngWebDriver ( a driver that implements protractor functionality) paul-hammant/ngWebDriver GitHub Link

  • I am getting error for both the xpaths; for first i got the error -stale element exception for the second i got , not a valid xpath – ravenclaw_93 Jun 26 '18 at 6:16
  • did you google stale element exception ? – Theo Jun 27 '18 at 7:14
  • @Theo-Yes I understand what stale element exception is – ravenclaw_93 Jun 27 '18 at 10:14
  • @shashi one of the reasons this exception is thrown, is that the element is no longer visible or present. If your test app is an angular one try using ngWebdriver a webdriver for angular (github.com/paul-hammant/ngWebDriver) OR protractor OR try implementing github.com/SeleniumHQ/fluent-selenium FluentSelenium will attempt to transparently get past the stale element exception business. – Theo Jun 27 '18 at 14:03
  • @shashi - the xpath expression is missing a double quote: driver.findElement(By.xpath("//div[@ng-class=‘config.title’]")).getText() – Mate Mrše Jul 5 '18 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.