How to run a command when clicking submit button (lua)? - lua

i want to use lua to generate cgi-webpages with uhttpd. What's the correct way to execute a shell command when a button (submit form), or a link is clicked?
Thanks

If you are asking for the specifics of what form the HTML would take and the server side scripts in order to do what you want, then your question is way too broad. If you're just wondering about the Lua side of running shell command:
The HTTP GET (link click) or POST (form) would cause one of your Lua functions to get called, wherein you would call os.execute('your-command'). However, due to the obvious security risk associated with calling os.execute, some environments that embed Lua disable certain calls. I don't know anything about the Lua modules allowed by uhttpd. With some luck, it supports the call, and it's up to you to make the proper checks if you want to use it.

Related

Is there a similar thing like EventFiringWebDriver to PlayWright automation?

My objective is to log all the interactions with the web elements in PlayWright automation. I need to capture the following interactions
Click/Submit
Select dropdown
Check Box
Text filling
Radio button
Toggle button
Something like as shown here https://blog.testproject.io/2018/06/04/event-listeners/
Hope it helps what I am trying to achieve, please do comment if further information is required.
Thanks.
Write wrapper functions over library functions to log desired details
Write wrapper functions over each UI action and which will write the specific action performed detail on an generally external file for later reference on post execution.
On the script level these wrapper functions will be called and all library functions will be called indirectly.
This is the standard advise to keep it DRY as there will be hardly 10-15 primary functions covering most of the UI actions and will encapsulate all the required logging & reporting functionality in one place.

process enter key using wx_erlang (erlang port wxwidgets)

I am building a simple browser in erlang, using wx. This simple browser has a text box for entering a url. I want to execute a callback when the user presses the enter key while in the text box.
I can see several potential ways of doing this, one option would be to process each keypress event, and execute its default action unless it is an enter key, in which case the custom processing occurs.
I was hoping there might be a higher level event I could use, like control lost focus. I am new to wx, and do not mind if programmers using other tools comment as the question (at this stage) is more about using wx that a particular language binding.
Not sure how is it called in wx_erlang, but there is wxEVT_TEXT_ENTER event to which you should bind. Note that you must create the control with wxTE_PROCESS_ENTER style to get this event.

How to disable textbox dropdown suggestions on certain websites?

I am trying to make my job easier by creating simple AHK scrips to auto-fill certain forms online.
Im not really good at explaining, but hopefully someone will understand what Im saying. The problem is that this website has certain textboxes with dropdown auto-suggestions turned on, and it has a delay when selecting those textboxes. I assume when selecting textbox it is pulling data from some database which is causing delay. Now my question is. Is it possible to turn off dropdown menu on websites or even in entire browser if necessary? I really want to my script to tab-in, wright down whats needed, tab-out without delay.
Autocomplete dropdown lists are just JS scripts. So there is no way, I think, to disable them by clicking checkbox in browser settings.
First, try to disable JS completely.
Also, if only few sites are involved, you could try to find out what JS libraries are used and disable them in browser JS console.
Are you planning to do this via keypresses or via COM?
I imagine that via keypresses you could not avoid focusing the elements and triggering the information lookup.
AutoHotkey can interact with webpages on Internet Explorer using COM (Component Object Model).
COM can launch/latch onto an IE instance, detect if the page is loading/has loaded, navigate to a particular url, and set the text of web elements,
quite possibly without triggering the drop-down lists. I haven't tested if COM can disable elements, it's possible.
Also, Acc.ahk may be able to set the text of elements.

Synchronous update of form data

This is basically a simple question, but I haven't found a good answer here or with Google.
We have a Ruby on Rails app with a form that needs to update a section when the user changes the selected option in a pulldown menu. The complication is that this update will be from the database - it can't realistically store and hide all the possible data when it loads. The obvious solution is an Ajax call, but the problem is that Ajax is asynchronous, and our update is inherently synchronous. We need to ensure that the user gets the updated info before submitting or doing any other work on the form.
I know one can (but shouldn't) specify that an Ajax call be synchronous, but is there a better approach to this? I hate to do a separate post and reload every time the user selects a different option in one field, but I'm not sure what the best practice is for a situation like this.
Update: I tried switching to using an XMLHttpRequest object in JavaScript, and it may work (I'm figthing with Rails routing issues right now), but it gives me a warning that the synchronous option for this object is deprecated. Is there really no accepted way to get synchronous communication between a web page and server?

Avoiding multiple executions in xforms-enabled

I am trying to launch a javascript for adding extra functionality to a form run. The script must be launch when the form is loaded.
The idea is:
<xxf:script ev:event="xforms-enabled">
alert('hello world');
</xxf:script>
The problem is, as described at the Orbeon Forum, the "xforms-enabled" event is launched several times (for each control and variable). In the forum is described some workarounds and solutions, but cannot be applied when using javascript (or I do not know how to do it).
The question is: how can I execute the javascript code only one time when starting the form? Must I use another event?
The best would be to run your script on xforms-ready, which is dispatched to the model. So you would put, inside your <xf:model>:
<xxf:script ev:event="xforms-ready">...</xxf:script>

Resources