WebPagetest Forums
Unable to trigger events using WPT script - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: General Discussion (/forumdisplay.php?fid=25)
+--- Thread: Unable to trigger events using WPT script (/showthread.php?tid=13167)



Unable to trigger events using WPT script - nccgroup_avi - 08-15-2014 01:48 AM

I am trying to script the following:

1. navigate http://www.avis.co.uk
2. exec document.getElementById('hire-search').click()
3. exec document.getElementById('hire-search').value='LHR'

I am not getting the map overlays on steps 2 & 3. It seems WPT is not triggering relevant events.

Can someone please give suggestion on how can I get map overlays to work using WPT script ?

Thanks,
Avi


RE: Unable to trigger events using WPT script - cshashank - 08-18-2014 09:47 PM

(08-15-2014 01:48 AM)nccgroup_avi Wrote:  I am trying to script the following:

1. navigate http://www.avis.co.uk
2. exec document.getElementById('hire-search').click()
3. exec document.getElementById('hire-search').value='LHR'

I am not getting the map overlays on steps 2 & 3. It seems WPT is not triggering relevant events.

Can someone please give suggestion on how can I get map overlays to work using WPT script ?

Thanks,
Avi


Try to use Javascript.

jvoid(document.getElementById("hire-search").value='LHR'


RE: Unable to trigger events using WPT script - pmeenan - 08-19-2014 02:54 AM

If you want to wait for something to happen you need to turn that last exec into an execAndWait. Otherwise it's not going to report anything and will just exit. You also need to either use a "combinesteps" command at the beginning or put the first navigate into a logdata 0/logdata 1 block so that only the overlay is measured.


RE: Unable to trigger events using WPT script - nccgroup_avi - 08-21-2014 01:11 AM

(08-19-2014 02:54 AM)pmeenan Wrote:  Thanks for your reply Pat! Tried following code but did not work:

logdata 0
navigate http://www.avis.co.uk
logdata 1
execAndWait document.getElementById('hire-search').click()
execAndWait document.getElementById('hire-search').value='LHR'


However I tried the following jquery calls in my Private instance of WPT:

logdata 0
navigate http://www.avis.co.uk
logdata 1
exec $('#hire-search').focus();
exec $('#hire-search').val('LHR');
exec $('#hire-search').trigger('keyup');

I could see the map overlays and auto-suggestions while it was executing the steps on the browser, but it did not capture any screenshots - http://www.webpagetest.org/result/140820_SF_7c6c973087a9311ec8882ccb5466b0d6/

Any idea why it would not capture screenshots when using jquery calls?

Finally got this working with jquery calls with screenshots and video:
http://www.webpagetest.org/result/140820_8C_48712e181ef1282a29d8d125c735280f/

Code:
combineSteps
navigate    http://www.avis.co.uk
execAndWait    $('#hire-search').focus();
execAndWait    $('#hire-search').val('LHR');
execAndWait    $('#hire-search').trigger('keyup');

Thanks everyone !