-
Notifications
You must be signed in to change notification settings - Fork 5
AutoGUI interaction #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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
|
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/