Hello, I would like to represent the following date format in regex but it is failing with the following error.
What is the proper regex that I need to specify in the script? Thanks. Below is the part of the script that I am using.
String time = Mobile.getText(findTestObject(‘Object Repository/Camera Page/Playback Date and Time (Version 121)’),10) //This takes a bit of time (because text keeps changing?)
int max = 3 //Do it max 3 times
int current = 0 //Set current to 0
while(time.equals("") && current < max) //If time is empty (didn’t load in time)
{
sleep(5000) //To give enough time for it to appear
time = Mobile.getText(findTestObject(‘Object Repository/Camera Page/Playback Date and Time (Version 121)’),10) //This takes a bit of time (because text keeps changing?)
current++
}
Mobile.comment("—Verify time string obeys regex (Month ##, Year HH:MM:SS (AM|PM) Timezone)—")
Mobile.verifyMatch(time, “[A-Za-z]{3} [0-9]{1,2}, [0-9]{4} [0-5]{0,1}[0-9]:[0-5]{0,1}[0-9]:[0-5]{0,1}[0-9] (AM |PM )?((?!UTC)[A-Za-z]{1,6}|UTC((-|\+)[0-9]{2})?)”,true)
04-28-2021 04:31:44 PM verifyMatch(time, “[A-Za-z]{3} [0-9]{1,2}, [0-9]{4} [0-5]{0,1}[0-9]:[0-5]{0,1}[0-9]:[0-5]{0,1}[0-9] (AM |PM )?((?!UTC)[A-Za-z]{1,6}|UTC((-|+)[0-9]{2})?)”, true)
Elapsed time: 0.056s
Unable to verify match between actual text ‘Apr. 28, 2021 16:29:55 GMT’ and expected text ‘[A-Za-z]{3} [0-9]{1,2}, [0-9]{4} [0-5]{0,1}[0-9]:[0-5]{0,1}[0-9]:[0-5]{0,1}[0-9] (AM |PM )?((?!UTC)[A-Za-z]{1,6}|UTC((-|+)[0-9]{2})?)’ using regular expression (Root cause: com.kms.katalon.core.exception.StepFailedException: Actual text ‘Apr. 28, 2021 16:29:55 GMT’ and expected text ‘[A-Za-z]{3} [0-9]{1,2}, [0-9]{4} [0-5]{0,1}[0-9]:[0-5]{0,1}[0-9]:[0-5]{0,1}[0-9] (AM |PM )?((?!UTC)[A-Za-z]{1,6}|UTC((-|+)[0-9]{2})?)’ are not matched using regular expression
at com.kms.katalon.core.keyword.builtin.VerifyMatchKeyword$_verifyMatch_closure1.doCall(VerifyMatchKeyword.groovy:57)
at com.kms.katalon.core.keyword.builtin.VerifyMatchKeyword$_verifyMatch_closure1.call(VerifyMatchKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:68)
at com.kms.katalon.core.keyword.builtin.VerifyMatchKeyword.verifyMatch(VerifyMatchKeyword.groovy:60)
at com.kms.katalon.core.keyword.builtin.VerifyMatchKeyword.execute(VerifyMatchKeyword.groovy:45)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.keyword.BuiltinKeywords.verifyMatch(BuiltinKeywords.groovy:73)
at New Test Case.run(New Test Case:69)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:398)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:389)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:368)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:360)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:255)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1619641697063.run(TempTestCase1619641697063.groovy:25)
)