Cannot find snackbar element
See original GitHub issueThe 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:
- Created 3 years ago
- Comments:13 (2 by maintainers)
Top GitHub Comments
https://appium.io/docs/en/commands/session/source/ is
Closed as not an issue