Methods for repeatedly clicking a button on a webpage (webview?)

Been enjoying the flexibility that BTT gives me over anything & everything on the computer... so many shortcuts so little time, am I right? :joy:

Anyway.. anyone have any ideas, best practice to repeatedly click on a webpage's button?

How about dozens of webpages with the same button, in the same position?

Given the breadth of the task and need for accessing many webpages what is the least memory/cpu intensive approach?

That depends a lot on what exactly you need to do / how the website is structured.

For example you could just combine the "Move Mouse to Position" action with the "Left Click" action. Or you could use the "Find Image On Screen & Move Mouse" action to search for the button, followed by a click.

Or you could run some Java Script in the browser to click the button.

Do you have a concrete example you can post? Then I could provide the best solution.

This is the webpage. It has a chart with data I will export via the top right button
'export chart data'

There will be many charts at different urls to access this way. They don't all need to be accessed concurrently, but being able to access dozens without delay will be crucial, so some concurrency.

There should be some way to ensure each page opened and the button clicked, so a method to avoid webpage timeouts, slow loading or other potential errors in this process.

Screen Shot 2023-10-25 at 4.38.18 PM

Screen Shot 2023-10-25 at 4.38.55 PM

Once the button has been clicked a few more pop-ups to handle, as shown above.

I'm also generally interested in how BTT can help automate or improve the process of scraping data from a webpage using the webview and scripting. And finally, triggering actions based on notifications or emails (Apple Mail) -- im guessing AppleScript?. Absolutely don't need a complete walkthrough, these tools are plenty help, just some direction would be great and I can get goin.

1 Like

Honestly I think you would be better off using some dedicated browser automation tooling like puppeteer/playwright. There are tools like https://github.com/checkly/headless-recorder that even let you record your user interactions to create the necessary scripts. //edit: headless-recorder seems to be deprecated as this is now directly integrated in playwright: Test generator | Playwright

You could do all of this with BTT somehow, but there are better tools for this.

1 Like

That looks great, I'll see what I can do with it.. GPT gave me the rundown just now of how it thinks BTT could be leveraged, it doesn't look too tough tbh, the whole things pretty slick:

Creating a Floating WebView:
Utilize the Floating WebView to create a custom interface which can load and display TradingView charts.
The Floating WebView allows for the triggering of various scripting functions via JavaScript, which can be employed to interact with the TradingView webpages​1​.
JavaScript Execution:
The key to automating the task is leveraging JavaScript to trigger actions within the TradingView webpages loaded in the Floating WebView.
Utilize the scripting functions provided by BTT such as trigger_named, trigger_action, or execute_assigned_actions_for_trigger to trigger predefined actions or custom scripts that interact with the TradingView webpages​1​.
Running Apple Scripts and Shell Scripts:
Besides JavaScript, Apple Scripts and Shell Scripts can also be executed right from within the WebView HTML using the runAppleScript and runShellScript JavaScript functions respectively​2​.
These scripts could be written to interact with the TradingView webpage elements, like clicking the 'Export Chart Data' button on each chart.
Error Handling and Recovery:
Design scripts to handle errors, timeouts, and other exceptional situations, ensuring the automation process recovers gracefully.
Utilize the JavaScript function fetch with bttweb:// links to send requests to BTT and handle responses, which can be used for error reporting or recovery actions​1​.
Concurrency:
To handle multiple charts concurrently, create separate instances of the Floating WebView, each loaded with a different TradingView chart.
Design the custom interface and scripts to handle concurrent operations, ensuring that actions on different charts do not interfere with each other.
Monitoring and Control:
Utilize BTT functions like display_notification to provide feedback on the automation process, notifying you of completed actions or encountered errors【
Establish a monitoring mechanism to track the status of the data export tasks, and potentially provide a manual override or intervention mechanism for exception handling.

ChatGPT is not too wrong, but it would be quite a bit of work and I'm not really sure whether you need this. BTT's floating web views allow lots of automation, but in your case - as I understand it - automating your standard web browser would be good enough or maybe even preferred.

Sounds good -- is there any chance that accessing the website via the webview is less resource intensive than a full Brave or Safari browser, especially as I need to access it constantly, and many different versions, preferably even several concurrently? Thanks for all this btw, much appreciated.

No - it should be pretty much equal to Safari's resource usage. Safari is using the same system frameworks.

1 Like