How to click find and click a button #1
GiuseppeChillemi
started this conversation in
Show and tell
Replies: 2 comments
-
|
Yes... that is how it is done. But it should be also noted, that you probably want to wait some time until the page is updated... like: results: write browser [
Runtime.evaluate [
expression: "document.getElementById('----IdOfTheButtonHere---').click();"
]
;; Wait until the page is loaded.
wait 'Page.frameStoppedLoading
;; Get 4 levels of the actual DOM.
DOM.getDocument [depth: 4]
]I can imagine that there could be some shortcut in the dialect.. like: results: write browser [
click "----IdOfTheButtonHere---"
DOM.getDocument [depth: 4]
]But maybe it should be in some higher level dialect. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Also it should be noted, that when you want to click some link, you may use results: write browser [
;; Click the first link on page
Runtime.evaluate [
expression: "document.querySelector('a').click()"
]
0:0:2 ;; wait 2 seconds
]or by link text: results: write browser [
;; Click the link with "Your Link Text" text.
Runtime.evaluate [
expression: "Array.from(document.querySelectorAll('a')).find(a => a.textContent.trim() === 'Your Link Text').click();"
]
wait 'Page.frameStoppedLoading ;; wait for specified event
]or by href attribute: results: write browser [
;; Click the link with exact HREF attribute.
Runtime.evaluate [
expression: {document.querySelector('a[href="/your-target.html"]').click();}
]
wait 'Page.frameStoppedLoading ;; wait for specified event
] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Open you web page and find the ID of the button you want to click, then use this code:
On the opened web browser it will be like having hit the corresponding button.
Beta Was this translation helpful? Give feedback.
All reactions