Daun
(Daun Lee)
February 1, 2020, 2:21am
1
I want to execute the below because it’s hard to get appropriate selector for the button.
document.querySelector(“body > div.modal.fade.seller-layer-modal.in > div > div > div.modal-footer > div > button.btn.btn-primary”).click()
It seems many people use the way of generating a .js file and executing it with “Inject JS Script” activity as follows.
But because it is too much for me I am wondering whether I can just pass the below
document.querySelector(“body > div.modal.fade.seller-layer-modal.in > div > div > div.modal-footer > div > button.btn.btn-primary”).click()
into this field.
Please let me know how the format should be if this is at all possible.
Thank you!
Hi
We can also pass the js script as a string here buddy like You can write it here as a string, or add the full path of a .js file which contains the code to be executed. * It should contain a single anonymous function as in the example below.
function (element, input) {
return "result";
}
Where:
element - represents the HTML element corresponding to the calling UI node.
input - the input string provided by the caller.
Cheers @Daun
1 Like
Daun
(Daun Lee)
February 1, 2020, 2:46am
3
@Palaniyappan , Thank you!
Could you give me the exact string to be put in the “ScriptCode” section
when I want to use this as a string?
document.querySelector(“body > div.modal.fade.seller-layer-modal.in > div > div > div.modal-footer > div > button.btn.btn-primary”).click()
rmunro
(Rene Munro)
February 1, 2020, 3:31am
4
Daun
(Daun Lee)
February 1, 2020, 3:44am
5
Thank you @rmunro for your answer.
So, is there no way of executing
document.querySelector(“body > div.modal.fade.seller-layer-modal.in > div > div > div.modal-footer > div > button.btn.btn-primary”).click()
like executing in the Google Chrome Console pane, ie., without creating a .js file?
rmunro
(Rene Munro)
February 1, 2020, 3:55am
6
Yes,
Just enter it between quotes like this: “document.querySelector(“body > div.modal.fade.seller-layer-modal.in > div > div > div.modal-footer > div > button.btn.btn-primary”).click()”
Daun
(Daun Lee)
February 1, 2020, 5:27am
7
@rmunro
It says I need to end the formula. Maybe because of the double quotations within it.
“document.querySelector(“body > div.modal.fade.seller-layer-modal.in > div > div > div.modal-footer > div > button.btn.btn-primary”).click()”
I tried putting 4 double quotations within it but it doesn’t work, either.
“document.querySelector(”“”“body > div.modal.fade.seller-layer-modal.in > div > div > div.modal-footer > div > button.btn.btn-primary”“”“).click()”
Daun
(Daun Lee)
February 1, 2020, 11:51am
8
“document.querySelector(‘body > div.modal.fade.seller-layer-modal.in > div > div > div.modal-footer > div > button.btn.btn-primary’).click()”
Single quotations in front of “body” and after “btn-primary” solved it!
1 Like
system
(system)
Closed
February 4, 2020, 3:37pm
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.