{"id":4740,"date":"2014-03-26T13:41:41","date_gmt":"2014-03-26T17:41:41","guid":{"rendered":"http:\/\/www.webperformance.com\/load-testing-tools\/blog\/?page_id=4740"},"modified":"2014-07-08T16:51:07","modified_gmt":"2014-07-08T20:51:07","slug":"inject-script","status":"publish","type":"page","link":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/articles\/real-browser-manual\/building-a-testcase\/scripting-support\/inject-script\/","title":{"rendered":"Inject Script"},"content":{"rendered":"<p>Inject a script (JavaScript) into the current page and run it. This is distinctly different from <a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/execute-script\/\">Execute Script<\/a>, which runs the script in the Virtual User (in Load Tester) rather than in the web page.<\/p>\n<p><em>Inject Script<\/em> uses a single datasource to provide the script that will be sent to the browser and executed. As an example, this simple 1-line script will enter a value into a text field with ID=&#8221;user_login&#8221;:<\/p>\n<p><a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2014\/03\/InjectScript-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4741\" alt=\"\" src=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2014\/03\/InjectScript-1.png\" width=\"543\" height=\"45\" \/><\/a><\/p>\n<p>A non-null return value from the script indicates an error. The return value will be converted to a string and used as the error message.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inject a script (JavaScript) into the current page and run it. This is distinctly different from <a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/execute-script\/\">Execute Script<\/a>, which runs the script in the Virtual User (in Load Tester) rather than in the web page.<br \/>\nInject Script uses a single datasource to provide the script that will be sent to the browser and executed. As an example, this simple 1-line script will enter a value into a text field with ID=&#8221;user_login&#8221;:<br \/>\n<a href=\"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-content\/uploads\/2014\/03\/InjectScript-1.png\"><\/a><br \/>\nA non-null return value from the script indicates an error. The return value will be converted to a string and used as the error message.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":4725,"menu_order":1,"comment_status":"open","ping_status":"open","template":"manual-page.php","meta":{"footnotes":""},"class_list":["post-4740","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/pages\/4740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/comments?post=4740"}],"version-history":[{"count":1,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/pages\/4740\/revisions"}],"predecessor-version":[{"id":4742,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/pages\/4740\/revisions\/4742"}],"up":[{"embeddable":true,"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/pages\/4725"}],"wp:attachment":[{"href":"https:\/\/www.webperformance.com\/load-testing-tools\/blog\/wp-json\/wp\/v2\/media?parent=4740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}