By now, I have to be on record at least a few thousand times in saying that WebPageTest.org is an absurdly valuable tool. Pat gave the performance community an incredible gift by building it and making it available to the broader community for free.
到现在为止 ,我至少要记录数千次才能说WebPageTest.org是一个非常有价值的工具。 Pat通过构建表演社区并将其免费提供给更广泛的社区,为表演社区提供了令人难以置信的礼物。
I spend a lot of time in WebPageTest. A lot of time. A while back, I made myself a little Alfred (like Spotlight but significantly more powerful and useful) workflow to make it easy for me to fire off a test quickly. It’s nothing fancy, but it does make it very convenient.
我在WebPageTest中花费了大量时间。 很多时间。 不久前,我为自己做了一些Alfred (类似于Spotlight,但功能更加强大和有用),使我可以轻松快速地进行测试。 没什么花哨的,但确实使它非常方便。
When I want to run a test on WebPageTest for any URL, I can open Alfred (I use CMD + Space for the hotkey) and then start typing wpt. When I do, a few options come up:
当我想对任何URL在WebPageTest上运行测试时,可以打开Alfred(我将CMD + Space用作热键),然后开始键入wpt 。 当我这样做时,会出现一些选择:
A screenshot of the options (listed below) for the WebPageTest Alfred workflow
WebPageTest Alfred工作流程的选项(下面列出)的屏幕截图
-
wptwptTest on a Moto G over a 3G network, from Dulles, VA (my most common test case, so I made it the default)
在弗吉尼亚州杜勒斯市通过3G网络在Moto G上进行测试(我最常见的测试用例,因此将其设置为默认值)
-
wpt:firefoxwpt:firefoxTest on Firefox over a cable connection, from Dulles, VA
通过VA Dulles上的电缆连接在Firefox上进行测试
-
wpt:chromewpt:chromeTest on Chrome over a cable connection, from Dulles, VA
通过弗吉尼亚州杜勒斯的电缆连接在Chrome上进行测试
-
wpt:safariwpt:safariTest on Safari over a cable connection, from Dulles, VA
从VA,杜勒斯通过电缆连接在Safari上进行测试
-
wpt:iphonewpt:iphoneTest on an iPhone 8 over a 3G connection, from Dulles, VA
通过VA Dulles通过3G连接在iPhone 8上进行测试
For each option, I type in the URL I want to test, press “Enter” and my default browser opens and fires up a test. Of course, I still need to go to WebPageTest.org directly for a lot of testing, but these commands are great for quick off-the-cuff tests.
对于每个选项,我键入要测试的URL,然后按“ Enter”,我的默认浏览器将打开并启动测试。 当然,我仍然需要直接进入WebPageTest.org进行大量测试,但是这些命令对于快速的现成测试非常有用。
I have a couple of default options enabled for each test:
我为每个测试启用了几个默认选项:
-
Number of runs: 3
运行次数: 3
-
Capture Video: true
拍摄视频: true
The workflow is pretty straightforward. For each keyword (like wpt) it passes the query to an “Open URL” action which has all the options passed along in the query string.
工作流程非常简单。 对于每个关键字(如wpt ),它将查询传递到“ Open URL”操作,该操作具有查询字符串中传递的所有选项。
Because the test gets passed to the public instance of WebPageTest.org by default, you need to use an API key (you can grab one for free courtesy of Akamai).
由于默认情况下测试会传递到WebPageTest.org的公共实例,因此您需要使用API**(您可以免费获得Akamai来获取一个)。
Since I decided to make the workflow available on GitHub, I didn’t want to hardcode the API key in the URL. Thankfully Alfred has some pretty slick environmental variables functionality that works perfectly for this. I also made the default run count and WebPageTest URL a variable, just in case anyone wants to default to a different number of test runs or use a private instance for testing.
由于我决定在GitHub上提供工作流程,所以我不想对URL中的API**进行硬编码。 值得庆幸的是,阿尔弗雷德(Alfred)具有一些漂亮的环境变量功能,可以完美地实现此目的。 我还将默认运行次数和WebPageTest URL设置为变量,以防万一有人希望默认使用其他数量的测试运行或使用私有实例进行测试的情况。
A screenshot of the environmental variables for the WebPageTest Alfred workflow
WebPageTest Alfred工作流程的环境变量的屏幕快照
As I mentioned, the workflow is up on GitHub for anyone who wants to take it for a spin. There’s a lot more I could do here—like make it possible to pass in the location or run count or some other variable dynamically—but it was meant to be a simple way to fire up WebPageTest quickly and for that, it has been working pretty well so far.
正如我提到的那样, 该工作流已在GitHub上提供,供任何想要试用的人使用。 我可以在这里做更多的事情,例如可以动态传递位置或运行计数或其他变量,但这是快速启动WebPageTest的简单方法,为此,它一直在正常工作到目前为止。
翻译自: https://timkadlec.com/remembers/2018-12-06-using-webpagetest-with-alfred/