click on button (by id)

230 views
Skip to first unread message

christophe fagot

unread,
Apr 26, 2022, 3:52:40 AM4/26/22
to AutoControl
Sorry my english is bad.
I want click a button with a script .

This code it's ok in console :
document.getElementById("C5_W15_V16_End").click();

but  when i use with autocontrol :
file21.js:1 AutoControl script: TypeError: Cannot read properties of null (reading 'click')

i am not a programmer sry
thk for answer

AutoControl support

unread,
Apr 26, 2022, 1:25:01 PM4/26/22
to AutoControl
The following should work:
image.png

Make sure the "Apply to" field points to the tab in which you expect the script to run.
The "current tab", as shown above, is the visible tab (the active one) in the most recently focused window.
You can use the "Run" button shown in the screenshot to test the script in a specific tab.

If you are sure that the script is running in the correct tab, then maybe the problem is that you are running it too early, before the page is loaded.
If you are using an event trigger such as Tab load begins, you should change it to Tab load ends so that the script runs when the page content is fully loaded.

If you are still unable to make it work, please post a screenshot of what you are doing so we can further assist.

christophe fagot

unread,
Apr 27, 2022, 3:05:35 AM4/27/22
to AutoControl
thank you for reactivity and your work .
firs time i want to block the ctrl + w for quit tabs this is it s ok
 and now i want click on a button.

I actually think that the problem comes from the active tab.


Capture1.PNG

try with console result it s ok  but not with AutoControl
Capture1.PNG

christophe fagot

unread,
Apr 27, 2022, 4:18:50 AM4/27/22
to AutoControl
testing

in console and after  with script Autocontrol :
console.log("click end with ctrl+w :");
console.log("console.log(document.URL)");
console.log(document.URL);

Results:
Capture1.PNG

I don't understand why.

AutoControl support

unread,
Apr 27, 2022, 1:56:18 PM4/27/22
to AutoControl
The URLs are different because the AutoControl script is running in the top frame whereas the console is running the code inside an inner frame.

image.png

This happens when you open DevTools by clicking on "Inspect" in the page's context menu.

In order to run an AutoControl script in a specific frame inside a page, you have to use the ACtl.runInFrames function.

christophe fagot

unread,
Apr 28, 2022, 3:57:39 AM4/28/22
to AutoControl
1000 THANKSSS

it run 

console.log("_______________click end with ctrl+w : START_________________");
await ACtl.runInFrames('#currentTab', {depth: 5}, ()=>{
    if(document.getElementById("C5_W15_V16_End")){
        document.getElementById("C5_W15_V16_End").click();
    }
}) ;
console.log("_______________click end with ctrl+w : end_________________");

Reply all
Reply to author
Forward
0 new messages