# Features 04 Other ways to create k6 scripts and CLI
<iframe width="560" height="315" src="https://www.youtube.com/embed/jEfrw5x2Cbk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
## Thumbnail
![[Features 04 - Browser recorder and k6 CLI.png]]
## Title
## What value do viewers get?
## Hook
## Intro
## Structure
- web script editor
- browser recorder (HAR > js)
- converters: [[HAR]], [[Postman]], [[OpenAPI]] ([[Swagger]]) - _low priority_
- `k6 login cloud`
- `k6 run script.js -o cloud`: application not publicly accessible, but results in cloud
- `k6 run script.js -i 1 -u 1`
- `k6 cloud script.js`: run on cloud
In the previous video, you learned how to create a test using the graphical user interface, the Test Builder, on k6 Cloud. In this video, you'll learn two other ways to create scripts.
First, you can use the k6 browser recorder. This recorder generates a k6 script from a browser extension, and it's available for Chrome and Firefox. I'm going to show you how to do it for Chrome, but the experience on Firefox will be similar.
From the Chrome Web Store, go to the k6 Browser Recorder extension and click Add to Chrome. Click on Add extension in the popup menu. If you don't see the k6 logo in your extensions, click on Extensions, find the k6 Browser Recorder, and then click on the little thumbtack icon to pin it to your toolbar.
Click the k6 logo and click Start Recording. It may take a few seconds to start up, but you should see text that says "Now recording". Now, navigate to your application and perform the actions you'd like to record. Make sure to let all the resources on the page load fully before continuing. When you're finished, click on the browser extension again and click Stop.
If you aren't signed into your k6 Cloud account, you'll be prompted to sign in. After you do so, you'll see a screen asking you to save your recorded test. On this screen, you can change the name of your test and decide whether you want your script to include correlation, static assets, sleep, and third-party domains. When you're done, click Save at the bottom.
You'll find yourself in the k6 Test Builder, where you'll see a list of the requests that were recorded, conveniently grouped into pages. For each request, you can also specify headers, query parameters, checks, and variables. From here, you can run your test the way you would any other Test Builder test.
You can also toggle over to Script view if you'd prefer to copy the script and run it locally instead of on k6 Cloud. This is particularly good for troubleshooting.
Another way to create k6 scripts is to write them in JavaScript using your favourite IDE. I'm using VSCode here. Start by importing modules-- here, I'm importing built-in modules so that I can make HTTP requests and add sleeps and checks in my script. Then, create a default function. This is what k6 will iterate through. My function includes a single HTTP GET request, a check for the response status code to verify that an HTTP 200 is returned, and a sleep.
To run the script, you can use the k6 CLI. k6 run test.js executes the script test.js with one iteration and one user. If you'd like to specify a number of iterations, try the `-i` and `-u` flags. Or, you could also include those in the script by adding test options.
What if you're ready to run the script on k6 Cloud? Type k6 login cloud, and you'll be prompted for your email address and your password. Enter them both.
Now, you can either run your test locally and send your results to k6 Cloud, or you can run the test on k6 Cloud itself. To run locally and send the results to the cloud, type k6 run test.js -o cloud. The -o stands for output. You'll see the test running in your terminal, along with a link that you can click on to follow along with the results of your local test.
To run your test on k6 Cloud, type k6 cloud test.js and click on the link to view the results of your test. If you use this option, your test will execute on our cloud rather than your local machine.
## Outro
In this video, I showed you two other ways to create k6 scripts: using a browser recorder and writing a test using JavaScript in your IDE. Then, I showed you some basic commands for the k6 CLI and how to use it to run tests locally, send your results to k6 Cloud, and how to run tests on your k6 Cloud account. In the next video, we'll go over how to analyze your load testing results on k6 Cloud.
## Related videos and resources
k6 Chrome browser recorder: https://chrome.google.com/webstore/detail/k6-browser-recorder/phjdhndljphphehjpgbmpocddnnmdbda?hl=en
k6 Firefox browser recorder: https://addons.mozilla.org/en-US/firefox/addon/k6-browser-recorder/
## Pre-production
- [ ] Take a thumbnail photo and create one for YouTube (1280 x 720).
- [ ] Add description.
- [ ] Include the title and any keywords in the first few sentences, but in a natural way.
- [ ] Add related videos and resources as links.
- [ ] Add end screen.
- [ ] Add cards if necessary.
- [ ] Add video to relevant playlist(s), or create a playlist if necessary.
- [ ] Create captions using Descript or using the script, then edit them.
- [ ] (For k6 videos) Send Floor thumbnail and video link for promotion.
- [ ] Add chapters for YouTube if longer than 5 minutes.
- [ ] Schedule on YouTube.
## Post-production
- [ ] Promote on personal social media.
- [ ] Twitter
- [ ] LinkedIn
- [ ] Create a blog post on [nicolevdh.com](http://nicolevdh.com)
- [ ] Include in a weekly newsletter.
- [ ] What other documentation can be created from this?