-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have script which on button press downloading file domain.com/zkau/view/z8/dwnmed-0/0ej1/File.xlsx always changing this part z8/dwnmed-0/0ej1/
Questions: 1. How to find which script code and how forming download url? 2. how catch this url in chrome console? 3. How debug such things?
There is a lot to talk about for selenium testing :)
Regarding finding components by IDs, there are 2 different ID sets. Client-side IDs are generated by an IdGenerator (which you can replace by a custom one if you want consistent client-side IDs), and server-side IDs set on your components are the same between page refreshes.
For example, if you define a button in zul:
<button id="myBtn" label="foo"/>
(or in java new Button(); btn.setId("myBtn"); etc.)
ZK will generate the client-side dom element for this button:
<button type="button" id="xyz123" class="z-button"...>foo</button>
the ID at client-side (xyz123) is the component's UUID. The ID at server-side (myBtn) is the component's ID.
You can use either to retrieve the component's dom node at client-side: zk.$('#xyz123').$n() //retrieves DOM node by client-side ID (UUID) zk.$('$myBtn').$n() //retrieves DOM node by server-side ID
Now, I don't know how the links which you need to click are generated in your application, but if you can give them a server-side ID (which stays the same between refreshes), you can just check if there is a component with that ID, and just do something like
widgetExists = zk.$('$myLinkId') != null;
to check if it exists currently
otherwise, selenium's waitForElementPresent is not a bad choice if you implement a custom IdGenerator
Regarding all of that, plus waiting for the scripts, the timing and processing, there is already more information in this article than what I'd be able to write here: https://www.zkoss.org/wiki/SmallTalks/2013/July/ZKTestingwithSeleniumIDE#Waitingfor_AJAX
Edit: regarding the error screenshot, are you using the server-side ID? that looks like a client-side UUID, which you can also select for, but using # instead of $. (see the selector doc in my previous answer) Anyway, as I mentioned client-side UUID is less useful since it refreshes with the page, unless you implement a custom ID generator
Hey there Rawas,
First question would be "what are you trying to debug"?
The zkau URI is a hash of the ZK version of the application and a few other things.
Regarding file download, if you have a page using ZK which downloads a files to the browser, the best way to do so is to use FileDownload: https://www.zkoss.org/wiki/ZKComponentReference/Essential_Components/Filedownload
The Filedownload feature just accepts a downloadable at server side, and does all of the required URL wiring for you. There is usually not reason for you to change these URLs, unless you have a very specific requirement.
In general, what are you trying to do? :) There is probably an already packaged way to do it regarding file download.
Alright, so your use case is that you want to check that the file is available while doing selenium testing?
If you just want to access a document from server-side, then the easiest option is to just have that document under the webapp folder. For example, if you put your file at /webapp/resources/myfile.xlsx, then it will be available at the url /yourapplication/resources/myfile.xlsx
However, in that case it is a direct download, and it's not testing your actual file download.
But in any case, if you are testing a ZK action which triggers a file download, the easiest option would be to trigger that action in the first place. If you put a selector on the zk button (or other component) which trigger the event, which in turn causes the filedownload, you should be getting the file in return.
I suggest reading up on zk object selection if you want to streamline your test cases ;) https://www.zkoss.org/wiki/ZKClient-sideReference/GeneralControl/Client-sideselectionofelementsandwidgets See this chapter: Zk widget DOM node selection
you can simply select a button's DOM node with "zk.$('$myBtnId').$n()" and trigger a seleniun click on it.
Also your code give me an error "zk.$('$myBtnId').$n()"
i.ibb.co/hXn6WCY/image.png
but how i can select node if it always changing his ID it dinamically changing, and POST data ID differs from form button ID
To download file from page (all thing only on client side) i need first press xlsx generation button, then wait some times and after press on each generated xlsx link. but xlsx link also dinamicaly formated on the fly throught hundred of methods and checks zkmx, zkme, zkx first event handled on
if (!(b9 = cb.handle)) { b9 = cb.handle = function (ci) { return typeof bH !== az && (!ci || bH.event.triggered !== ci.type) ? bH.event.dispatch.apply(b9.elem, arguments) : aD }; b9.elem = b5 }
then
function B(W, X) { if (!X) { X = 0 } if (W && X >= 0) { setTimeout(function () { zAu.sendNow(W) }, X) } }
then
function f() { var i = b(); if (i != d) { d = i; zAu.send(new zk.Event(null, 'onBookmarkChange', i), 50); zk.bmk.onURLChange() } }
then
function x() { e(zk.processMask) } function f(z, y) { return function () { return y.apply(z, arguments) } }
function G() { var ac = b, ad = P, W; try { if (ac && ac.readyState == 4) { b = P = null; if (zk.pfmeter) { zAu._pfrecv(ad.dt, s(ac)) } W = ac.getResponseHeader('ZK-SID'); var Y; if ((Y = ac.status) == 200) {
...etc
Asked: 2022-10-03 21:55:13 +0800
Seen: 12 times
Last updated: Oct 04 '22
How to stop combining commands in an ajax call ?
zk developmet is esay [closed]
Need help with scrolling horizontal tabs in Right-to-Left (Arabic)
Create tab dynamically, multitab application
Radio button value change on database value
How to implement, each user has its own session timeout time