ChromeSetElementValue, how to use?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 426
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

ChromeSetElementValue, how to use?

Post by Grovkillen » Mon Mar 23, 2020 12:47 pm

Hello,

Great update with Chrome being part of the arsenal of tools. I'm a bit puzzled on how to use the set element value. See the below example code. I'm not able to update the body. I was hoping that I could inject some html code here and there but is it only used for inputs?

Code: Select all

ChromeStart>strSessionID
ChromeNavigate>strSessionID,url,https://www.google.com/
ChromeFindElements>strSessionID,css selector,body,strElementID
ChromeSetElementValue>strSessionID,strElementID_1,THIS SHOULD BE REPLACING THE BODY INNER HTML?
**BREAKPOINT**
ChromeQuit>strSessionID
EDIT: I since writing this found this thread>> which pretty much deals with the thing I try to accomplish.

Note to self, here's the suggested code to inject stuff into the current session:

Code: Select all

Let>CHROMEDRIVER_EXE=C:\Program Files (x86)\Macro Scheduler 15\chromedriver.exe
Let>CHROMEDRIVER_PORT=12

ChromeStart>strSessionID
ChromeNavigate>strSessionID,url,https://www.google.com/
ChromeFindElements>strSessionID,css selector,body,strElementID
GoSub>ExecuteJS,strSessionID,document.body.innerHTML=\"THIS SHOULD BE REPLACING THE BODY INNER HTML?\";


SRT>ExecuteJS
  Let>HTTP_POSTJSON=1
  Let>body= { "script": "%ExecuteJS_Var_2%", "args": [] }
  Let>CHROMEDRIVER_PORT=9515
  HTTPRequest>http://localhost:%CHROMEDRIVER_PORT%/session/%ExecuteJS_Var_1%/execute,,POST,body,theResult
END>ExecuteJS


**BREAKPOINT**
ChromeQuit>strSessionID
Let>ME=%Script%

Running: 15.0.9

User avatar
Marcus Tettmar
Site Admin
Posts: 7156
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: ChromeSetElementValue, how to use?

Post by Marcus Tettmar » Mon Mar 23, 2020 1:45 pm

Yeh SetElementValue sets the TEXT or VALUE. But you want to REPLACE the HTML. Different things. Hence augmenting it by injecting javascript.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Grovkillen
Automation Wizard
Posts: 426
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: ChromeSetElementValue, how to use?

Post by Grovkillen » Mon Mar 23, 2020 1:58 pm

Marcus Tettmar wrote:
Mon Mar 23, 2020 1:45 pm
Yeh SetElementValue sets the TEXT or VALUE. But you want to REPLACE the HTML. Different things. Hence augmenting it by injecting javascript.
Thanks for the feedback. +1 in making this subroutine a command. :)
Let>ME=%Script%

Running: 15.0.9

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts