WebPagetest Forums
Sending script down to runtest.php - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: Bugs/Issues (/forumdisplay.php?fid=10)
+--- Thread: Sending script down to runtest.php (/showthread.php?tid=11977)

Sending script down to runtest.php - Nicholas Godfrey - 01-11-2013 09:34 PM


I've been using webpagetest for a long time, scripting Jmeter and Jenkins to get CI perf graphs and it's great. But now I need to send a webpagetest script down to runtest.php

I'm posting the name value pair 'script' but I can only get it to work for a one line script.

I want to navigate to a page, enter some log in info and press the log in button. The script works manually but in the POST, the first navigate key word wants to take the whole script as it's input. I've tried \n and \r to specify new lines but am not getting anywhere.

How would I get this to work for example:

name=script value=navigate <my first url>\nsetValue name=signIn_emailAddress <my email>\nsetValue name=signIn_password <password>\nclickAndWait name=signIn_signInButton

this works ok:
name=script value=navigate <my first url>

and if I add the \n on the end of that, it just shows up in the browser on the end of the url...


RE: Sending script down to runtest.php - pmeenan - 01-12-2013 12:49 AM

I believe the POSTs are usually expecting to be mime encoded but I've never looked to be honest - you can watch what your browser posts to see what is going on. You can send it through get as a query param as well, just make sure to urlencode it (that is the most common cause for API calls failing).

RE: Sending script down to runtest.php - Nicholas Godfrey - 01-12-2013 03:03 AM

I have tried GET as well and here's a simpler example. Any ideas on getting this working?

sent this down:
GET /runtest.php?url=http://webwob.com/index.html&runs=1&f=xml&r=12345&fvonly=1&location=Office_wptdriver:Chrome&noimages=1&script=navigate%20http://www.webwob.com/index.html%5Cnnavigate%20http://www.webwob.com/html/faq.html HTTP/1.1

with these headers:
MIME-version: 1.0 (generated by my-application 1.2)
Content-Type: multipart/mixed

but got back:
<?xml version="1.0" encoding="UTF-8"?>
<statusText>Please enter a Valid URL. <b>http://www.webwob.com/index.html\nnavigate http://www.webwob.com/html/faq.html</b> is not a valid URL</statusText>

Again, if I simplify this to:
GET /runtest.php?url=http://webwob.com/index.html&runs=1&f=xml&r=12345&fvonly=1&location=Office_wptdriver:Chrome&noimages=1&script=navigate%20http://www.webwob.com/index.html%5Cn

that last \n is appended to the url

Any ideas on getting the '\n' used to split up the script?

This page (https://sites.google.com/a/webpagetest.org/docs/advanced-features/webpagetest-restful-apis) doesn't give any details and line 958 on this page (http://code.google.com/p/webpagetest/source/browse/trunk/www/webpagetest/runtest.php?r=1614) suggests that the script should be split on "\n".

Thanks for any help on this,

RE: Sending script down to runtest.php - pmeenan - 01-12-2013 04:33 AM

Your GET request is not properly URL Encoded. Here is a site I usually use to try things out: http://meyerweb.com/eric/tools/dencoder/

Here is what it should look like:

RE: Sending script down to runtest.php - Nicholas Godfrey - 01-14-2013 09:03 PM

Thanks. I had used a similar encoding site but had typed \n into notepad myself. Now, when I cut and paste from notepadd++ with it's own carriage returns, it looks like your example below. This is great! Thank you so much for the support. It's working and I can now automate a proper workflow.

Kind regards,