Scripting Not Working On Private Instance

Hi guys, I was hoping that someone could help me out with this. I am trying to test the scripting functionality of my local instance of this product, but even the most basic scripts don’t seem to work. I have confirmed that my script works at webpagetest.org, but when I try the exact same script on my local instance, it fails. Could I be missing something in my configuration or has anybody else experienced this issue and knows of a fix. My script looks like this(tab-delimited, not spaces):

logData 0
navigate http://www.mysite.com
logData 1
navigate http://www.myothersite.com

Any advice would be greatly appreciated.

Edit

I figured, I would add the errors that I am getting when I attempt to test this script on my local instance.

If i run it through the UI, I get the following error:

The testing completed but failed.
Timed out waiting for the browser to start.
Waterfall Screen Shot Video
First View: Test Data Missing
Repeat View: Test Error: Skipped repeat view, first view failed: Timed out waiting for the browser to start.

In reality, I am writing a simple php script using curl to start tests, collect the test results and store results in a database. An example of the curl call I am using to start the test is below:

$link = urlencode(file_get_contents(‘test.txt’));

$startTest = curl_init();
curl_setopt_array($startTest, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => ‘http://www.mylocalinstance.com/runTest.php’,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
‘location’ => ‘Office_wptdriver’,
‘f’ => ‘json’,
‘script’ => $link,
‘video’ => 1
)
));

$response = curl_exec($startTest);
curl_close($startTest);

//The script continues from here to check the test status then collect the results once it has been completed.

If i remove the script option and manually specify single URLs, using the url option, the script runs fine and all data is stored correctly. However, when I use the script option and point to my URL encoded version of the script file I wrote, I get the following error:

{“statusCode”:400,“statusText”:“Invalid Script (make sure there is at least one navigate command and that the commands are tab-delimited). Please contact us if you need help with your test script.”}

The URL encoded script looks like this:

logData%090%0Anavigate%09http%3A%2F%2Fwww.yahoo.com%0AlogData%091%0Anavigate%09http%3A%2F%2Fwww.aol.com%09%0A

I have also tested this without encoding my script file with the same results. There are definitely navigate commands in my script and they are tab-delimited so I’m not sure what I am doing wrong.

I have also verified that all necessary PHP modules from the installation documentation are installed on the server, so I don’t believe that is a problem.

Logs don’t seem to give me any truly useful information to narrow down the issue.

Anyone else experiencing or have experience this? Any help would be greatly appreciated.

I tried your script on my private instance, and it works. I just spinned up a standard webpagetest AMI, didn’t change anything, so default settings work. I have however had a problem with the agent initially, where browsers were not installing, unless I remote desktop into the agent and watch it. :smiley: But if URLs work fine for you, and it is only the script that fails, shouldn’t be that. Maybe double check that you run script with the correct location/browser settings just in case? It can also help to remote desktop into the agent you are using and to watch what’s happening when you run the test. You might see the reason browser is not starting in the wptdriver window.

I got the same error as you when I was curling my scripts just two days ago, the problem was in the encoding. The string you provided has extra characters after aol.com, can that be a problem? I also noticed that you are not passing API key with curl. Did you disable having to provide keys? If not, you need to provide a key, they are stored in the settings/keys.ini on the server.

Hope at least some of this was useful.

Hi Hali, thanks for your reply. That is odd as I am running a local instance with the default settings for everything as far as I can tell. I am running the server with PHP 7, I am not sure if maybe that could cause an issue.

I do not have the optional programs installed such as imagemagick or exiftool as I was attempting to keep this as basic as possible. I have verified that all required programs/modules/etc are installed by navigating to www.mylocalinstance.com/install and all required items have green checks.

I only have one agent installed so by default, it should and does hit the correct location(I do manually tell it what location to use anyway, but I am not telling it which browser).

I have logged into to my server to watch the tests run and its odd. If I run the script from inside the browser(GUI), the browser(Chrome) pops up, but it is never able to locate the pages I am trying to navigate to and the test fails, however, when I attempt to run it in the script that I wrote, it errors out before it even makes it to the server and with the error from my original post(Invalid Script).

I didn’t notice the extra characters after aol.com, but I will look at that and see if maybe that resolves the issue.

Per your question about an API key, as far as I know since this is a private instance, I do not need one. I believe it is possible to set it up to use one, but I have no use for that if I don’t need it. If it is a requirement to run scripts, I will gladly set up a key, but I’d like to be sure that is the issue before I spend the time on it.

Thanks again for your reply. At the very least, you gave me a few extra things to verify and a good place to begin troubleshooting. If my response helps you think of anything else, please let me know.

**** Update ****

So I went ahead and upgraded my private instance to 3.0 and now I can use the scripting feature in the browser. I used the following script(tab-delimited) just to test:

logData 0
navigate www.yahoo.com
logData 1
navigate www.yahoo.com

This works perfectly. I get basic data for both URLs and the it stores screenshots and other stuff for the URL that I told it to log.

Unfortunately, my issue with running a script with the API persists. No matter what I have tried I receive the following error:

{“statusCode”:400,“statusText”:“Invalid Script (make sure there is at least one navigate command and that the commands are tab-delimited). Please contact us if you need help with your test script.”}

I am writing this in PHP using simple CURL calls to start, get test status, and pull the JSON results.

I have tried just passing the file itself like so(I also tried with absolute path):

$startTest = curl_init();
curl_setopt_array($startTest, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => ‘http://mywebpagetest.com/runTest.php’,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
‘location’ => ‘Office_wptdriver’,
‘f’ => ‘json’,
‘script’ => ‘nav.txt’
‘video’ => 1,
‘iq’ => 100
)
));

I have tried encoding the file into a php variable and passing that to the script option like this:

$link = urlencode(file_get_contents(‘nav.txt’));

$startTest = curl_init();
curl_setopt_array($startTest, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => ‘http://mywebpagetest.com/runTest.php’,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
‘location’ => ‘Office_wptdriver’,
‘f’ => ‘json’,
‘script’ => $link,
‘video’ => 1,
‘iq’ => 100
)
));

This also produces the same error. In a prior post someone mentioned that it looked like i had an extra space at the end of my encoded file so I did something like this which also fails.

$link = urlencode(file_get_contents(‘nav.txt’));
$linked = substr($link, 0, -3);

$startTest = curl_init();
curl_setopt_array($startTest, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => ‘http://mywebpagetest.com/runTest.php’,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
‘location’ => ‘Tools_Agent’,
‘f’ => ‘json’,
‘script’ => $linked,
‘video’ => 1,
‘iq’ => 100
)
));

Anyone have any ideas?

I just tested this on our 3.0 server and the api call works fine.

The call looks like this:

http://yourserver.com/runtest.php?script=logData+0 navigate+http%3A%2F%2Fwww.yahoo.com logData+1 navigate+http%3A%2F%2Fwww.yahoo.com&location=InsertLocationHere&runs=1&fvonly=1&connections=0&web10=0&video=1&timeline=0&f=json&tcpdump=0&noopt=0&noimages=1&noheaders=0&pngss=0&noscript=0&iq=100&htmlbody=0&ignoreSSL=1

Hope this helps,

Pete