RESTful API testing requires base64 parm - btoa() is unknown function
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RESTful API testing requires base64 parm - btoa() is unknown function
How can I encode a binary file to base64 for the API parm?
I found https://support.smartbear.com/viewarticle/42195/ but it requires dotnet and the desktop license for TC. We are only using the web testing so the example fails.
Is there anyway to access the native javascript window.btoa() function within javascript test scripts?
Eddie
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Eddie,
Assuming that your project is either JScript- or JavaScript-based, this link might help: https://scotch.io/tutorials/how-to-encode-and-decode-strings-with-base64-in-javascript
Also https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/javascript.html might be relevant as well.
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I resolved it by doing something similar but different to the example on scotch.io. VERY slow.
The TC project is running pure javascript. We're not even opening a browser, just httprequests to exercise the API. There is no page object to use as in the documentation link you provided.
We may have to open up a browser just to have a page object to use to improve the speed.
Thanks,
E
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> Is there anyway to access the native javascript window.btoa() function
As per w3schools (https://www.w3schools.com/jsref/obj_window.asp), window is not a native JavaScript object, but an object that "represents an open window in a browser".
Also note that as per https://www.w3schools.com/jsref/met_win_btoa.asp, btoa() is not supported in IE browser.
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
