Get part of text from URL

I am using PuppeteerLibrary for my robotframework and I have this keywords.

Get URL
${tempURL}=    Get Location
Log    URL is ${tempURL}

After execute the keyword, it will log
URL is https://xxxxx.xxx/xxxxxxxxxxxxxxxxx/ipolid=123456/aaaaaa.com

My problem is, how can we get part of the text from the URL, for example
I will get “ipolid=123456” only and log it.

is that possible ?

Hi Wei Sheng,

StringLibrary is probably what you’re looking for, it has useful keywords like Split String, Fetch From Right, Get Regexp Matches and many more.

  • You could easily do what you want with a regex
  • if you’re not comfortable with regex, use Split String split the string by the / character, then use Fetch From Right to get the part after the = in ipolid=123456 or use Split String again splitting on the =

there are probably many many other ways to do this too including using the builtin Evaluate to use python split or regex functions directly, but the string library is a nice easy to read solution.

Hope that helps,

Dave.

Hi Dave,

Thanks for the suggestion. I will try it out. Hopefully StringLibrary can run in Gitlab.