AutoGUI interaction#36
Merged
GJFR merged 36 commits intoDistriNet:devfrom Nov 13, 2024
szymsza:dev-auto-gui
Merged
Conversation
Member
|
I took a first jab at merging. The button for creating a url queue and interaction script isn't displayed currently. This is partly due to the hacky way in which experiment folders are distinguished from files like I'm gonna have a more in-depth look at how to properly solve this later. BugHog/bci/web/vue/src/components/poc-editor.vue Lines 295 to 297 in e815589 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After trying out the devtools protocols in BugHog, the two simple implementations I had prepared worked only for Chromium 70+ and Firefox 127+. Even though there were some other protocols implemented in previous browser versions, it would require a lot of effort to implement all of these and correctly match them to the supported browser versions. Further, there would likely be no way to target versions approx. 20-50.
As a result, I decided to use PyAutoGUI as you suggested. It works in all browsers and versions and for practical usage it seems almost as good as the devtools protocols.
Instead of
url_queue.txt, users can choose to provide the experiment configuration ininteraction_script.cmd. These are the commands implemented so far:NAVIGATE urlTerminates the previous browser window and opens a new browser window on the specified URL. Further, it waits some time (1 sec for Chromium, 2 secs for Firefox) for the page to load.CLICK_POSITION x yClicks on specific coordinates on the screen (not necessarily the browser window), The argument values can be absolute in pixels, percentage of the screen, or a combination of both - e.g.,CLICK_POSITION 100 50%clicks 100px from the left screen border and 50% of the screen height.CLICK element_idClicks on an element with the specified ID. Currently, the ID can be one ofone,two,three,four,five,six. This is because PyAutoGUI can search for the location of a visual match on the screen. Therefore, I prepared styles inres/bughog.cssthat style elements with these IDs to boxes of distinct colors. This allows us to bypass the limitation of having to know the exact screen coordinates of an element.WRITE textTypes the text into the focused element.PRESS keyHOLD keyRELEASE keyHOTKEY key1 key2 ...A combination ofHOLDandRELEASEfor multiple keys. E.g.,HOTKEY ctrl c.SLEEP secondsUsually should not be necessary to use because navigation implicitly includes sleeping.SCREENSHOT file_nameCaptures the screen and stores the result inlogs/screenshots/{PROJECT}-{EXPERIMENT}-{file_name}-{BROWSER}-{VERSION}.jpg. Very useful for debuggingA simple experiment can be found in
Support/AutoGUI. It got successfully reproduced in all versions of both browsers.We can possibly implement some browser-specific behaviour as well, e.g., bookmarking a string where the script would include only
BOOKMARK textand based on the browser version, the correct shortcut would be pressed and screen positions clicked.Besides this, I made the following changes:
interaction_script.cmdandurl_queue.txtfrom the web UIinteraction_script.cmdin the experiment editor/res/