Does Protractor provide a native way to check requests going out from events such as a button click?
For example, onClick(), a POST request is made to https://myapi.net/customers and I'd like to, during my test, make an assertion on the Request URL.
I've seen some npm packages that might be provide some help, but looking through the Protractor API's, I can't seem to find anything that would handle this out of the box.
Thanks!
One simple way to do is to use browser.driver.getCurrentUrl()
Preceding approach will provide the current url on browser but if you are interested in url which is triggered after click button then i am not aware how we deal this in webdriverJs but in .Net there is Support.Event namespace which provide the way to do action after ElementClicked event.
Related
Encountered a problem accessing my tracks from browser.
Usually i type this link in my browser to access downloadable tracks:
http://api.soundcloud.com/tracks/294324164/download?client_id=02gUJC0hH2ct1EGOcYXQIzRFU91c72Ea
But now i can not access it anymore, probably the client id is changed.
How can i obtain a new client id?
Thanks.
Simple.. Go to any tracks that you can download on soundcloud, press f12 and look at networks tab, click download and it will show you something like
https://api.soundcloud.com/tracks/322109493/download?client_id=2t9loNQH90kzJcsFCODdigxfp325aq4z&oauth_token=2-274121-85658-y9KQYyZ6qG9oT2uvPq
Grab that client_id, replace it and amend the url from download? to stream?.. use streams? if you want a list of urls in json format
http://api.soundcloud.com/tracks/294324164/stream?client_id=2t9loNQH90kzJcsFCODdigxfp325aq4z
As no one else has mentioned it, in a Chrome-based browser under DevTools ctrl+shift+i, you can grab your client_id from the Network tab on reload. Many items listed here reference the SoundCloud API and require your client_id to access it. Simply click any item in the list that isn't an image/base64 item (preferably something that begins with id?...), then check the Request URL for a client_id.
It's the simplest way to grab the ID; now that you know how, don't do anything illegal k thx.
For those thinking this is the same as the other answer mentioning a download link, this method skips that entirely as many songs are no longer available from SoundCloud itself, but from external sources that are linked instead.
Amazing it's been this long, yet there's no "public" Soundcloud API. I'm amazed to find something worse off than the Twitch API.
See this user's solution for a way to do this without a CLIENT ID which you can no longer get from soundcloud: https://stackoverflow.com/a/27461646/179571
youtube-dl https://soundcloud.com/my-fav-artist
seems to work and pull all tracks as mp3
no client_id needed, if you needed the client_id to get something
like soundcloud-dl to work
You can apply for a client ID by filling in the SoundCloud Application Registration form.
I use the AjaxFallbackLink component for an Ajax link. When I mouse-over the link, the URL looks something like ./myPage?1-1.ILinkListener-xxx. And when I actually click the link, however, the Ajax request looks something like: ./myPage?1-1.IBehaviorListener-xxx.
It seems that Wicket JavaScript has somehow changed the URL from ILinkListener to IBehaviorListener. Wonder if it is so, and why is that?
Sometimes in certain circumstances ILinkListener in the URL is not changed to IBehaviorListener when the request is sent out by the browser, which causes NullPointerException as parameter AjaxRequestTarget target in the callback function is null. I haven't been able to reproduce this. Just wonder what browser settings could cause this to happen. Thanks a lot.
Both of those URLs are correct.
The first static link address './myPage?1-1.ILinkListener-xxx.' is a generic link address for a link in case it invokes a URL and process the link.
The second AJAX link address './myPage?1-1.IBehaviorListener-xxx' is a generic JavaScript/AJAX behavior. In case when JavaScript is working, the JavaScript is attached as an onclick event (see jQuery click() function at https://api.jquery.com/click/) and it processes the link, then it shouldn't continue to process the URL from HREF attribute.
So far you would expect to request only one of those URLs when the link is clicked. But in case of AjaxFallbackLink when there is no AJAX then onClick(AjaxRequestTarget) is invoked as onClick(null), it causes NPE if you rely on existing AjaxRequestTarget object, but there is no guarantee for that.
The last part of your question is not clear when it is not possible to reproduce. But Wicket uses jQuery, if you add jQuery library into the HTML, there is a possible conflict of versions.
There are some more detail on a similar issue at http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackLink-s-onClick-with-null-AjaxRequestTarget-migrating-1-4-to-6-td4652143.html
I'm basically looking at a security problem between a parent page and an iframe with links to a third party.
I want to send a POST or a GET (doesn't matter which as I can control the other side) to the third party, but not expose any details within it (say a SID or a user token) and have it's HTML content (JS/HTML/Images) loaded into the iframe.
I've looked at server-side redirects, creating a proxy using webclinet/webresponse and am curious to whether there is a good way to do it.
Has anyone ever done this before, or think that the secrity is not possible? Hell, even if I'm barking up the wrong tree on how to solve this.
If anybody has any examples on this it would be greatly appreciated.
Cheers,
Jamie
[Edit] Was thinking I might need to add some more details.
Say I have a parent page: https://mycompany.com/ShowThirdParty.
This has an iframe in it at the moment which will have the content of another component (also owned by me, or another team more specifically)
Basically I'd like to send some credentials to content in the iframe in such a way that the external pages can't read it, the iframe is put into a modal (I've done that) and the iframe has the restricted content with the auhtentication almost seamless and invisible.
I currently have it working as a GET url generated dynamically via JS and then passed into the iframe src parameter, obviously that isn't secure.
I kind of want some kind of server side redirect across a full url, but I don't even think that's possible.
You could try using AJAX and load a PHP script (with any parameters to the script encoded/encrypted) to query the 3rd party page and load the response into the iframe. Not really sure how your code is setup but there should be a way.
It can also be done by POST Method (submit the data to iFrame using POST) as it is HTTPS so the data you send to iFrame is encryped.
My web site has a design where a grid of records is shown. For each record the user might edit it (a GET request) or change its status (this should be a PUT). Do I have a way of doing this without using Javascript?
That is, my current options are:
Use Javascript in a link handler to change the request type as needed.
Separate the GET and PUT activities to separate web pages.
Do the status change via a GET and turn a blind eye to REST specifications right here.
Are there other options?
Thanks,
Jerome.
A GET should not have any side-effects and a PUT would replace the whole resource at the location given by the URI. So the former should be a POST. The latter should be as well, unless it does in fact send the whole resource. A POST is possible without Javascript, obviously.
I'm currently working with lift and I recently faced a difficult with redirects.
When I try to show an error or notice with S.error, it redirects to the page which I was previously. And I couldn't find a work around for that. I assume it's a default behavior of lift and there should be a work around. Please post how to changed this behavior.
It's unlikely that S.error is causing the redirect.
I presume you're calling S.error while processing a form submission. If so, you need to call S.redirectTo or S.seeOther after your processing is complete to redirect the browser to a different page. If you don't Lift's default behaviour is to reload the form on which you have just clicked submit.