I’m trying to do a test to check if when I try to log in without a password the error message appears in the form “Fill in this field.”, but I’m not able to get this error message.
WebUI.openBrowser('')
// Navega para a página de login
WebUI.navigateToUrl('http://localhost:3000/')
// Insere o e-mail válido
WebUI.setText(findTestObject('Object Repository/Login_Page/input_Login_email'), 'teste@gmail.com')
// Não insere a senha (campo da senha ficará vazio)
WebUI.setEncryptedText(findTestObject('Object Repository/Login_Page/input_Login_password'), '')
// Clica no botão de login
WebUI.click(findTestObject('Object Repository/Login_Page/button_Enter'))
// Espera 5 segundos
WebUI.delay(5)
// Verifica se a mensagem de erro do campo senha está aparecendo
WebUI.verifyTextPresent("Preencha este campo.", false)
// Fecha o navegador
WebUI.closeBrowser()
1 Like
Hi @ppetrilii96,
Welcome to our community. I believe that this thread is similar to How to get form error message so I will close the other and let’s focus discussing on this. In your code, I think you setEncryptedText still trigger the input so the error might not be shown, also instead of checking for text, verify the input field’s validationMessage
attribute. Please try the following code and let me know if works
WebUI.openBrowser('')
// Navega para a página de login
WebUI.navigateToUrl('http://localhost:3000/')
// Insere o e-mail válido
WebUI.setText(findTestObject('Object Repository/Login_Page/input_Login_email'), 'teste@gmail.com')
WebUI.click(findTestObject('Object Repository/Login_Page/button_Enter'))
WebUI.delay(2)
String validationMessage = WebUI.getAttribute(findTestObject('Object Repository/Login_Page/input_Login_password'), 'validationMessage')
WebUI.verifyMatch(validationMessage, "Preencha este campo.", false)
WebUI.closeBrowser()
1 Like
Great to hear so. I will mark that as solution for the others to refer to. Happy testing!
1 Like