Current time: 12-15-2017, 04:59 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running scripts with RESTful APIs
04-06-2015, 11:52 PM
Post: #1
Running scripts with RESTful APIs
Hi,

I am using the RESTful APIs for automating tests. I found the documentation here https://sites.google.com/a/webpagetest.o...tful-apis.

This works well when i have a single web page to run a test against. But i have the scenarios where i need to go to first page, e.g login fill in some values, and the run tests on a different page.

I have used the script feature from the webpagetest home page but i want to use the scripts with restful api. Going through the documentation i found the RESTful API allows script but i could not find any documentation for passing the script to the API.

Any help is appreciated.
Find all posts by this user
Quote this message in a reply
04-07-2015, 01:00 AM
Post: #2
RE: Running scripts with RESTful APIs
The API has a "script" parameter (should be documented on the REST API docs page). If you are using HTTP GETs to talk to the API make sure to urlencode the script first.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-07-2015, 10:07 PM
Post: #3
RE: Running scripts with RESTful APIs
(04-07-2015 01:00 AM)pmeenan Wrote:  The API has a "script" parameter (should be documented on the REST API docs page). If you are using HTTP GETs to talk to the API make sure to urlencode the script first.

Thanks Patrick for the quick reply. I tried running the test using Get as well as post. Here are some of issues I faced.

Using Get
I get a HTTP Status 200 back on the API response. With the <jsonUrl>**</jsonUrl> returned I can see the test is executing. But finally the test fails. here is one the result.
http://www.webpagetest.org/result/150407_WM_M1X/
Using Post
I am always getting the following error. The script has the navigate command and tab delimited. I am using the same script i use in the script tab in the home page.
I am using application/x-www-form-urlencoded for post. Seems I am missing something here.

<statusCode>400</statusCode>
<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.
</statusText>
Find all posts by this user
Quote this message in a reply
04-07-2015, 10:30 PM
Post: #4
RE: Running scripts with RESTful APIs
Check your script and encoding. Looking at the script that was used in the test, it has tabs followed by 3 spaces separating the commands and values.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-24-2017, 02:04 AM
Post: #5
RE: Running scripts with RESTful APIs
what are the correct separation? I haven't found nothing on it..
I've tried all spaces; spaces+tabs; spaces+tabs+newline; tabs+newline. All encoded and all failed (((

here is the simple script to test:
logData 0
navigate https://google.com
logData 1
navigate https://facebook.com


and one of the tried POST:
POST http://www.webpagetest.org/runtest.php

POST data:
label=testApi&location=ec2-eu-west-1%3AChrome%3ANative&runs=3&fvonly=0&script=logData+0+navigate+https%3A%2F%2Fgoogle.com+logData+1+navigate+https%​3A%2F%2Ffacebook.com&video=1&k=...&tcpdump=1&mobile=1&tester=IP-AC1F1799&timeline=1&ignoreSSL=1

[no cookies]

Request Headers:
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 282
Host: http://www.webpagetest.org
Proxy-Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.3.1 (java 1.5)



And all I get is always - "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.
"
Find all posts by this user
Quote this message in a reply
05-26-2017, 01:54 AM
Post: #6
RE: Running scripts with RESTful APIs
Correct separation is tabs. If you are sending it as POST data it needs to be mime-encoded form input, otherwise url-encoded as query params on the URL itself.

something like runtest.php?...&script=logData%090%0Anavigate%09https%3A%2F%2Fgoogle.com%0AlogData%091%0Anav​igate%09https%3A%2F%2Ffacebook.com
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)