Skip to content

Instantly share code, notes, and snippets.

@belajargitbinar
Last active January 17, 2024 13:52
Show Gist options
  • Save belajargitbinar/8f89c5690bf5752cee1ce4542b5ceede to your computer and use it in GitHub Desktop.
Save belajargitbinar/8f89c5690bf5752cee1ce4542b5ceede to your computer and use it in GitHub Desktop.
Get Javascript Field Error Message
import com.kms.katalon.core.util.KeywordUtil
import com.kms.katalon.core.webui.driver.DriverFactory
import org.openqa.selenium.By
alert_id = 'Isi isian ini.'
alert_en = 'Please fill out this field.'
def driver = DriverFactory.getWebDriver()
def field_login = driver.findElement(By.id('user_email'))
def message = WebUI.executeJavaScript("return arguments[0].validationMessage;", Arrays.asList(field_login))
if ((message==alert_id)||(message==alert_en)) {
if (message==alert_id) {
KeywordUtil.markPassed('Error appear in ID language')
} else {
KeywordUtil.markPassed('Error appear in EN language')
}
} else {
KeywordUtil.markFailed('Validation Error Message Not Appear')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment