WebUI.getUrl() strange behavior with home URL

I am not sure if this is a bug or a different matter, but this is how it goes:

I am currently writing a script that is performing a check if all of the URL types meet the company’s guidelines.

Everything behaves as expected, buuuut… except for the main page. Here’s the algorithm:

  1. I define an array for different URLs
  2. I invoke an ‘incorrect’ URL that must be redirected to a correct one
  3. I use WebUI.getUrl() to get the de facto URL
  4. I check it using a regex

Everything was neat, until I stumbled upon this issue:

  1. I have a de facto URL of https://www.something.lv
  2. I check it with a wildcard (with Groovy slashes around) /https\:\/\/www\..*\.lv/
  3. I get a fail on the check (because it has to be true)
  4. I change it to /https\:\/\/www\..*\.lv\//

The step 4 does not meet with our guidelines, but, in any browser, I don’t see the ending slash which is found by Katalon.

Possibly, this is a question for a webmaster, but I’m just curious if you guys can give me some insight for the matter.

P.S. Googling didn’t bring me no results, so I had to try it the empirical way.

Your thoughts?

P.P.S. The code itself (I’m just testing it in alpha, so don’t laugh :smiley: (but really, laugh if you feel like it))
// Define a $testUrlArray variable with Urls that we need to address and check afterwards
String[] testUrlArray = [
http://somesite.lv’, // [0] 1.1.1
http://www.somesite.lv’, // [1] 1.1.2
http://somesite.lv/lat/elektronika-1/tv-un-video/?manufacturer=219&screen_resolution=25217’, // [2] 1.2
https://www.somesite.lv/’, // [3] 2.1
https://www.somesite.lv/eng’, // [4] 2.2.1
https://www.somesite.lv/lat/bernu-mode/meitenem-1/dzhinsu-apgerbi’, // [5] 2.2.3
https://www.somesite.lv/rus/warranty-and-returns/14-days-return’, // [6] 2.2.4
https://www.somesite.lv/rus/sadzives-tehnika/iebuvejama-tehnika/ledusskapji?manufacturer=1161&price=2000-5000’, // [7] 2.3.1
https://www.somesite.lv/eng/catalog/product/view/id/558422/s/lg-49sk8000-49sk8000plb-aee.html/’, // [8] 2.4.1
https://www.somesite.lv/rus/catalog/product/view/id/520191/s/chairman-9801-ergo-7015599.html/?adwords=test’ // [9] 2.4.2
assert testUrlArray instanceof String[]


// First we type a ‘wrong’ category URL into the address bar and go
WebUI.navigateToUrl(testUrlArray[0])def currentUrl = WebUI.getUrl()

// Then we perform a check on the wildcard. We continue if it fails
WebUI.verifyMatch(currentUrl, /https://www…*.lv/, true, FailureHandling.CONTINUE_ON_FAILURE)

Let’s take this one step at a time:

Well, that’s a shame because the root folder marker (the ending /) is used to signify “give me the default document at this path”. When you neglect to provide it, the browser (or server, if it gets that far) adds it in for you. That is why you’re seeing it supplied for you.

Actually, today, none of what I said is strictly true, but it’s true in practice, or, as you like to call it, de facto.

So this…

… is “more correct”. I say “more correct” because there is more to the restrictions on URL chars than using .*

As to what Katalon is doing to retrieve the URL, it’s probably asking the browser via webdriver. You can do the same by pressing Alt-D, Ctrl-C and then paste into a text file. You will see a site seemingly WITHOUT the trailing slash certainly does contain one.

p.s. I’m 99.99% certain, almost “de jure sure” this isn’t a bug so I’m moving it. If you can come back with a statement as to why it is a bug (possibly ending with QED) I’ll willingly move it back. :nerd_face:

1 Like

Thanks for the answer. I just got feedback from our webmaster and he stated the same (excerpt from Google):

Note that the absolute path cannot be empty; if none is present in the original URI, it MUST be given as “/” (the server root).

So this thing sets it straight.

So there’s no way to check it this way. Will be thinking about checking if it’s possible to check if there’s a possible workaround.

Thanks again :slight_smile:

1 Like

You’re absolutely correct, it’s a web ‘feature’, you did the right thing

1 Like

Thanks for getting back.

Now this is what I call a neat thread. Done and dusted in a few posts. :slight_smile:


1 Like