I am retrieving various services triggered in the network tab in a list and then validating the URLs. For one of the service, the URL triggered is dynamic in nature. The URL contains a unique code(as highligted in below screenshot) and with each run that unique code changes. I need to validate the URL for testing purpose but since it is dynamic in nature I am not able to hardcode the URL in my code.
Can you please suggest how can I validate that URL or bypass the unique key and just validate the first part of URL and the last part of URL(as shown in the screenshot I want to validate till snapshot and then tha last part of the URL,i.e, save)?
You can match it with a regex.
If the hex-string (marked up in red on yellow in your screenshot) is always 24 characters long…
If it varies in length…
If it’s length is within a fixed range of say 8 to 24 digits:
Actually I tried your solution but I am facing one issue. I have ‘?’ in one the service URL and two unique code is genetated in the URL that I am fetching but ‘?’ is used as a regular expression so it is taking as a special character so to resolve the issue I am trying '' to escape the special characters as shown in the screenshot.
But the issue is, it is throwing a error when I am using '' to escape the special character in Katalon. Katalon is not accepting any backward slash in the code. Could you please tell me how can we resolve the issue?
Code I am using to validate the URL -
it =~ ‘https://dgbsctcc.telecomitalia.local:8444/sieble/st-dues-v2/st/tunnels/[a-zA-Z0-9]+/cart\?focus=cmp[a-zA-Z0-9]+&hierarchy=Y&type=VERTICAL’
KeywordUtil.markFailedAndStop(‘Url not present’)
You wanted to print
'\' rather than
‘’, didn’t you?
Then you need to write this in Markdown syntax: quote your string by a pair of backticks `…`
I am trying `'\'` to escape...
Also you should use a pair of triple backticks to format lines of code for better representation:
A single character (e.g.
\) matters much in a Regular expression. Therefore you have to write your post in appropriate syntax of Markdown if you want to discuss about Regular expressions. Otherwise people can not understand you.
As for escaping a
\ character in a String literal, have a look at
'an escaped escape character: \\ needs a double backslash'
The “trick” is not to use quotes at all, use slashy strings for regex. This avoids any co-opted use of quoted strings the language itself might be using for interpolation.
/^your regex here$/
When you need to escape characters (like ?) use a \
/^your regex\? here$/