Typing Facebook Pixel in a Box

Hi all,

One important task I need to achieve is to click a box, and then paste/type the Facebook Pixel.

The pixel has 2 variables on it which I’m passing, like so:
<!-- Facebook Pixel Code --> <script>!function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '${!cmd_var2}'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=${!cmd_var2}&ev=PageView&noscript=1" /></noscript> <!-- End Facebook Pixel Code -->

However whenever the type or Xtype step arrives:

  • <!-- End Facebook Pixel Code --> is dropped (which is actually non important being a comment)
  • The closing </noscript> is dropped.

So the pixel pasted is:
<script>!function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '${!cmd_var2}'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=${!cmd_var2}&ev=PageView&noscript=1" />

I really need the pixel text pasted as is without dropping anything… as mentioned I tried both Type & XType. Any suggestions?

To avoid this issue, try copy and paste:

  • store | your pixel code here | !clipboard <= Copy code to clipboard

  • XClick | xpath=.... <= set focus on the box (a normal CLICK should also work)

  • XType | ${KEY_CTRL+KEY_V} <=send ctrl+V to insert code from clipboard

Can You explain the problem because I don’t understand what kind of problem have and with what ui vision command.

Type paste every text you want

Thanks but the result is exactly the same, the very same parts are completely omitted from the clipboard.

Mh I tried to be as clear as possible, I’m not sure how to explain better… Part of the Facebook pixel text mentioned above is just omitted from the text, whether I copy it, type it, xtype it, or anything at all. With copying it’s even worse:
"<!-- Facebook Pixel Code --> <script>!function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '${!cmd_var2}'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=${!cmd_var2}&ev=PageView&noscript=1" /></noscript> <!-- End Facebook Pixel Code -->"

Turns to:
!function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '${!cmd_var2}'); fbq('track', 'PageView'); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=${!cmd_var2}&ev=PageView&noscript=1" />

Your problem do not exist, type working like a charm this is the screen

Probably your macro cose is wrong and need to be fixed or created with better commands

Your macro cose have variables not saved and characthers not escaped.

I believe the reason it is not working for me, is becasue I’m saving it as HTML (with autorun), as I need to run it from a file. Then the part that is recognised as HTML, isn’t saved. You can try that if you have the possibility.

Ilya

Try a better store command or use replace and split or regex to clean the text stored

This could be. “HTML (with autorun)” as a way to run macros is deprecated, because it is no longer needed. You can achieve exactly the same (and more!) with the command line. Instead of opening the the HTML file to run the macro, you would instead click on a shortcut or a batch file or a shell script to run the macro. You also find more info on the “API” tab on the RPA settings page:

image

Hi can you add more details about this feature please ?

What is the difference betwin this feature and old HTML file used to run macro via command line ?

Thanks

The new autostart HTML works like a charm (and makes my processes about 40% easier), AWESOME!

Ilya

1 Like

The old HTML file method copies the complete macro into an HTML table. This is the old Selenium IDE V2.x format. The only advantage of this format is that you can import it back into Selenium IDE. You need to create such a macro specific HTML page for every macro that you want to launch from the desktop or script.

The new API method to launch a macro uses always the same “dummy” Autostart HTML page. You can create this page once with the big blue button on the API settings page. Then you add &macro=MACRONAME to the HTML page local file URL. To run other macros, just change the macro name.

1 Like