I would like to save part of the URL and I don't really know how to do it. I would like to save the part of the URL in a variable.
Anyone has an idea how to do it?
First, to get the current url, use
current_url = WebUI.getUrl()
Then you will need to use some kind of string manipulations to get the part that you need.
Katalon uses Groovy language, so you can read about the string methods here.
For example, if current_url='https://www.tutorialspoint.com/groovy/groovy_strings.htm' you wish to get only the part of the url after the last / try something like this:
split_url = current_url.split('/')
partial_url = split_url[split_url.size()-1]
println partial_url
The result of the above is "groovy_strings.htm".
Related
I'm working on a test plan with Jmeter.
The issue is that I can't retrieve the URL link as he is managed dynamically.
The URL has the following format:
localhost\blablabla?PATHPARAM=qzflh%2FGJHBGDCV%GROPJHVFFFDDFGGCFD%JJYTGVFRTVFGGFF%JUYGBG
I already try to search the value of PATHPARAM in the previous requests to retrieve it using regular expression extractor but I didn't find it.
It seems that this url is generated inside a javascript code but the way to extract it is unknown for me, inside the js code I find the value : var url = actionName + "?" + params ;
Is that any way to catch the content or the var url in Jmeter, else have you any other solution to solve this issue with this dynamic URL.
Many thanks in advance for your help.
I can see 2 possible options:
If you are being redirected to this URL automatically (you might need to play with Redirect Automatically and Follow Redirects boxes in the HTTP Request sampler
If this is the case - you should be able to get it using the following Regular Expression Extractor configuration
If you need to replicate the logic of this param variable calculation - you can attempt to do it using JSR223 PreProcessor which can execute arbitrary JavaScript code
In ColdFusion, I understand how to work with URLs using the query string functions: i.e., the second parameter in:
test.cfm?par1=val1&par2=val2&par3=val3
can be accessed by:
<cfset Param2 = ListGetAt(CGI.QUERY_STRING,2,"&")>
However, I was tasked with making dynamic URLs with the parameters separated simply by slashes, i.e.:
test.cfm/val1/val2/val3
How can I construct a URL this way, and then utilize those parameters in the webpage it links to?
Edit: I understand it would be quite easy to construct a string that is "test.cfm/#val1#/#val2#/#val#" and use it as my URL; I was wondering if there was a cleaner, built-in way for CF to help me do it. I am still lost on how to access those in the page.
Param2 = listChangeDelims(CGI.QUERY_STRING,"/","&");
That will turn "foo=bar&sna=fu" into "foo=bar/sna=fu".
Or listChangeDelims(CGI.QUERY_STRING,"/","&=");
will change it to "foo/bar/sna/fu"
I'm not sure if I can accomplish this with Lua, but I want to take the data from the following URL:
http://www.roblox.com/Trade/InventoryHandler.ashx?token=%22&filter=0&userid=1210210&page=1&itemsPerPage=14&_=
and store it in a variable so I can manipulate it.
Is there any way I can do this?
To save a string as a variable it is as simple as
foo = "contents of string"
To manipulate the string, you would use the string library
If you want the text at the URL instead of in the url, see the link to the previously asked question I added in the comments
I'm trying to build an Href using Razor
The string is going to end up looking like this:
https://www.notmysite/controller/action?order_ID=xxxxxxx&hashComparator=iFxp3%2BszAMaEB%2FnHCtRr9Ulhv0DumtyDumCik4gKypJqi0BdOGXXsr9QDkfefAsLaR1Xy%2BrX9VcuzP1pF2k6dL%2F92UxphzTKqNAZP2SSZGWtvyO5az%2F9JvDY%2Bsq5TBQo7%2FYAAMIU4QxiSX1SBKk8SUNECW3ZmKM%3D
In my model I have the order id and the hash string
As the route is not a part of my site I don't believe I can use the default methods like #Url.Action
and therefore can't use protocol: Request.Url.Scheme
like I've used elsewhere.
So at present I'm trying to figure out how to create this using string functions
I've tried
Url.Encode
Url.EscapeDataString
Html.Encode
but am getting no where fast:
Click Here to be transferred
The output text always has plusses and equals in them and doesn't work.
Which combination do I need?!
I've figured out a way of doing it:
#{
var url = string.Format(
"https://www.notmysite.co.uk/controller/action?order_ID={0}&hashComparator={1}",
#Uri.EscapeDataString(Model.bookingNumber.ToString()),
#Uri.EscapeDataString(Model.hashCode));
}
<p>Click Here to be transferred</p>
Edit 2015 - As mentioned by Jerads post - The solution is to only encode the query string elements and not the whole URL - which is what the above does.
This was the first link that came up for this issue for me. The answers didn't work for me though because I am using core, I think. So wanted to add this in.
System.Net.WebUtility.UrlEncode(MyVariableName)
If Url.Encode doesn't work try the above. Also as stated before don't use this on the entire URL string, just use it for the individual querystring variables. Otherwise there is a good chance your URL wont work.
The problem is that you're trying to encode the whole URL. The only pieces you want to encode are the querystring values, and you can just use Url.Encode() for this.
You don't want to encode the address, the querystring params, or the ? and & delimiters, otherwise you'll end up with an address the browser can't parse.
Ultimately, it would look something like this:
Click Here to be transferred
The easier method is to use #Html.Raw(Model.SomethingUrl)
I am looking for a tool(class or method or ...) in Yii that, get a string (a url) and return an array contains module, controller, action and other get_params.
I cannot use explode because it is possible that module dose not exists or can not find out that 'a/b' is module/controller or controller/action !
This is kind a weird of Yii - why I can't just do something similar to:
$this->uri->segment(1);
Many FWs have this feature, so simple and obvious.
PS Also, why I should write methods in Helpers like above to do things FW must definitely do? And yes I don't want to act like:
$request = new Request();
$request->setUrl('/site/contact');
Yii::$app->urlManager->parseRequest($request);
This is totally stupid, not after setting the url - just f***ing grab it like in old wonderful days. They should write an alternative either.