question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find snackbar element

See original GitHub issue

The problem

I’m doing some tests, to automate some validations of the email fields, but the Android application, when submit it to the form, if I put a bad format of mail, the app launches a snackbar with the validation message.

The problem comes that I have tried all the possible selectors (accesibilty id, name, text, class etc) to validate the text inside this snackbar but in no way can I find the element.

Environment

  • Appium version 1.17.1
  • Ubuntu 18.04.4 LTS
  • Node.js version 10.13.0
  • Npm
  • Android 9
  • Real device
  • Appium CLI/Appium inspector

Details

If necessary, describe the problem you have been experiencing in more detail.

Appium logs

2020-06-05T06:39:43.693Z INFO webdriver: DATA { using: ‘accessibility id’, value: ‘Enter a valid email’ } 2020-06-05T06:39:49.035Z INFO webdriver: RESULT [] 2020-06-05T06:39:49.037Z INFO webdriver: COMMAND setImplicitTimeout(1500) 2020-06-05T06:39:49.037Z INFO webdriver: [POST] http://localhost:4723/wd/hub/session/3c7ff75b-8aee-497f-8cf2-49178f2c06bd/timeouts/implicit_wait

Code To Reproduce Issue

// javascript

const wdio = require("webdriverio");
var tools = require('./helpers/email_validation');

const opts = {
  path: '/wd/hub',
  port: 4723,
  capabilities: {
    platformName: "Android",
    platformVersion: "9",
    deviceName: "Android",
    app: "somethingApp.apk",
    automationName: "UiAutomator2"
  }
};

async function main () {
    const chalk = require('chalk');
    var errorCounter = 0;
    var results_per_test = [];
    try {
      const client = await wdio.remote(opts);
      let loginLink = await client.$("//android.widget.TextView[contains(@resource-id,'labelAlreadyAcc')]");
      client.setImplicitTimeout(5000)
      await loginLink.click();
      const signup2 = await client.$("//android.widget.Button[@text='LOGIN']");
      await signup2.click();

     //Empty email
     let element = await client.$$("~Please introduce an e-mail");
     client.setImplicitTimeout(1500)

      if(element.error == undefined){ //if theres no error response
        console.log("RESULT 1: " + chalk.green('Empty email validation working'));
        results_per_test.push(chalk.green("\u2714 - Empty email validation working"));
      }else{
        console.log("RESULT 1: " + chalk.red("Check empty inputs validation not working"));
        results_per_test.push(chalk.red("\u2716 - Check if can process all input empty"));
        errorCounter++;
      }
      if(errorCounter > 0){
        console.log(chalk.red("FINAL RESULT: " + errorCounter+ " Validations not working"));
      }else{
        console.log(chalk.green("FINAL RESULT: All Validations working correctly"));
      }
      console.log('Tests Execution Summary')
      results_per_test.forEach(function(entry) {
        console.log(entry);
      });


    } catch (err) {
      console.log(err);
      console.log("RESULT: " + chalk.red('Test Not Finished Successfully'));
    }
    }

    main();

Basically when giving the submit of the form, with the empty email field, he returns a message with the text “Please enter an e-mail” inside a snackbar, so if he finds the item, I apply a validation to counter that said validation is working

But just as you see in log, appium says RESULT [] an empty array without the element.

Any suggestion am I skipping something? Or there is no support for this type of item?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

0reactions
mykola-mokhnachcommented, Jun 10, 2020

Closed as not an issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to locate MatSnackBar element in protractor e2e test
Hi, did you tried to add .then(() => browser.sleep(60_000)) and manually check that the element by tag name 'simple-snack-bar' is indeed present ......
Read more >
Flutter: Showing SnackBar within the Widget that builds a ...
It happens because the current context doesn't contain a Scaffold. Even though we see that our build function returns Scaffold. Context starts to...
Read more >
Snackbar - Angular Material
open. Opens a snackbar with a message and an optional action. Parameters. message. string. The message to show in the snackbar. action. string...
Read more >
SnackBar class - material library - Flutter - Dart API docs
To display a snack bar, call ScaffoldMessenger.of(context).showSnackBar() , passing an instance of SnackBar that describes the message.
Read more >
Snackbar API - Material UI - MUI
Name Type Default action node anchorOrigin autoHideDuration number null
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found