Project

General

Profile

Automate remote write of value to a WSpinBox or WText

Added by Jim Fred over 10 years ago

I have a witty app with several WSpinBox fields on several WStackPane objects. The WSpinBox has valueChanged() events that are handled by the C app and this all works well from a web browser.

I'd like to have the option to automatically poke or write values to a WSpinBox from a C program or a bash script on a client computer. The Wt app would ideally see little difference between manual data entry via a browser or automatic pokes from a script posing as a user. The purpose is to use the web interface as an API for remote applications without the need to implement and maintain a separate API.

Another option I see is to create a new REST API interface and I found some solutions on this forum to implement a REST service and consume the service using curl. This might be better for high-bandwidth data transfer but I'm looking for a simpler approach for occasional testing or prototyping.

I realize that there are 2 aspects to this question: [1] remote manipulation of a generic field on a webpage and [2] the Wt-specific details such as the 'id' or 'name' attributes of the input field. I'm asking about both aspects - how might I use something like curl or a C app to poke a value 'x' into a field 'y' for a Wt app at address 'z'?


Replies (1)

RE: Automate remote write of value to a WSpinBox or WText - Added by Wim Dumon over 10 years ago

Hello Jim,

For testing, Koen has recently published a blog post on how to use Selenium for testing Wt applications, which answers a big part of your questions:

http://www.webtoolkit.eu/wt/blog/2013/05/13/selenium_node_locators_for_wt_and_jwt_applications/

Interacting with the UI from a curl script is nearly impossible. This is a consequence of Wt's security mechanism, which means you'll have to properly initiate a session from curl, make your way through the UI to the fields you want to update, and then generate the right queries to modify the results. This is easy for a browser to do, but if you make a small mistake somewhere, Wt will kill your session for security reasons.

So for automation, build a REST interface.

BR,

Wim.

    (1-1/1)