Chrome Driver - Traverse Iframes & Insert HTML
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
1. This code will not replace the ENTIRE HTML. It will only replace the innerHTML of the BODY. document.body is the body tag.
2. Javascript needs quotes to be escaped. Because of the way you are extracting the body I expect the JS is erroring because there are unescaped quotes. E.g. " needs to be come \"
2. Javascript needs quotes to be escaped. Because of the way you are extracting the body I expect the JS is erroring because there are unescaped quotes. E.g. " needs to be come \"
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
Ah, I would very much like that.Marcus Tettmar wrote: ↑Tue Mar 03, 2020 10:40 amAgain, if this is something people find useful we can turn this into a native function.
- Dorian (MJT support)
- Automation Wizard
- Posts: 1380
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
Marcus Tettmar wrote: ↑Tue Mar 03, 2020 8:59 pmWell, since we were working on this anyway and it was further ahead than I thought, I managed to reprioritise a few things and get an update pushed out today with added native ChromeSwitchFrame and EdgeSwitchFrame functions. Version 15.0.07. Available in the usual places.
It's already there, Grovkillen, see above.Grovkillen wrote: ↑Mon Mar 23, 2020 12:53 pmAh, I would very much like that.Marcus Tettmar wrote: ↑Tue Mar 03, 2020 10:40 amAgain, if this is something people find useful we can turn this into a native function.
Yes, we have a Custom Scripting Service. Message me or go here
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
I thought I was referring to the "ExecuteJS". Instead of having a custom sub routine it would be ideal to have it taken care of with a command.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
Code: Select all
Still struggling with this...
CODE: SELECT ALL
GoSub>ExecuteJS,session_id,document.body.innerHTML=\"<p>blah blah</p>\"
Works almost as expected, although instead of replacing the entire page, it actually just replaces everything inside the page body tag.
This does not "replace entire document".
You could try setting document.innerHTML which I believe is a new HTML 5 feature supported by SOME browsers. I haven't tried it. It may not work. Give it a go. Another possibility is document.write(newDocument). Again I haven't yet tried it. Give it a go.
Also see:
https://stackoverflow.com/questions/675 ... e-document
But the long and short of it is that you have some javascript code which sets the inner html of the BODY element and seem surprised that only the BODY element is being updated. But that's what the code does.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
I would love to have a execute JavaScript command. Together with a " to /" flag. It could then be used almost like the vbscript and python implementation is working now.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
Not sure I follow. Can you explain?Grovkillen wrote: ↑Mon Mar 23, 2020 6:54 pmI would love to have a execute JavaScript command. Together with a " to /" flag. It could then be used almost like the vbscript and python implementation is working now.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
The ExecuteJS sub routine in your code example work just great. But couldn't that be made into a command?
ChromeExecuteJS>sessionID,JSCode
Instead of:
And what I meant by having a flag for the " is that it would be great to not have to care about adding the \ in front of the " before passing the code to the command.
ChromeExecuteJS>sessionID,JSCode
Instead of:
Code: Select all
Let>CHROMEDRIVER_EXE=C:\Program Files (x86)\Macro Scheduler 15\chromedriver.exe
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
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
Yes. It’s on the list already. The more these new functions get used the more ideas/requests/use cases emerge.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
Ah, great!Marcus Tettmar wrote: ↑Mon Mar 23, 2020 8:58 pmYes. It’s on the list already. The more these new functions get used the more ideas/requests/use cases emerge.
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
Is this being implemented Marcus? *fingers crossed*
- Dorian (MJT support)
- Automation Wizard
- Posts: 1380
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
I'll ask at MJT Towers.
Yes, we have a Custom Scripting Service. Message me or go here
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Chrome Driver - Traverse Iframes & Insert HTML
Thanks!! Will try.