Skip to content

Instantly share code, notes, and snippets.

@gvc
Created June 27, 2024 16:57
Show Gist options
  • Save gvc/09847f51e06cc060f448ec6c1d75b501 to your computer and use it in GitHub Desktop.
Save gvc/09847f51e06cc060f448ec6c1d75b501 to your computer and use it in GitHub Desktop.
starter-2024-06-27-14h00
// Creator: Grafana k6 Browser Recorder 1.0.4
import { sleep, group } from 'k6'
import http from 'k6/http'
import jsonpath from 'https://jslib.k6.io/jsonpath/1.0.2/index.js'
export default function main() {
let response
const vars = {}
group('page_2 - https://starter.vtex.app/aedle-vk1-headphone-99988211/p', function () {
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientShippingSimulationQuery&operationHash=d6667f1de2a26b94b9b55f4b25d7d823f82635a0&variables=%7B%22items%22%3A%5B%7B%22id%22%3A%2299988211%22%2C%22quantity%22%3A1%2C%22seller%22%3A%221%22%7D%5D%2C%22postalCode%22%3A%2294102%22%2C%22country%22%3A%22USA%22%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientSearchSuggestionsQuery&operationHash=a8a27661f6a032e086c047339e0d0f180f0e0161&variables=%7B%22term%22%3A%22%22%2C%22selectedFacets%22%3A%5B%7B%22key%22%3A%22channel%22%2C%22value%22%3A%22%7B%5C%22salesChannel%5C%22%3A%5C%221%5C%22%2C%5C%22regionId%5C%22%3A%5C%22v2.4325C29BA00E6470CBA54999680076F9%5C%22%2C%5C%22hasOnlyDefaultSalesChannel%5C%22%3Afalse%7D%22%7D%2C%7B%22key%22%3A%22locale%22%2C%22value%22%3A%22en-US%22%7D%5D%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientManyProductsQuery&operationHash=c0d7d2ae1d5aaae5d50eea683b389377c36fb57d&variables=%7B%22first%22%3A5%2C%22after%22%3A%220%22%2C%22sort%22%3A%22score_desc%22%2C%22term%22%3A%22%22%2C%22selectedFacets%22%3A%5B%7B%22key%22%3A%22view%22%2C%22value%22%3A%2299995944%22%7D%2C%7B%22key%22%3A%22channel%22%2C%22value%22%3A%22%7B%5C%22salesChannel%5C%22%3A%5C%221%5C%22%2C%5C%22regionId%5C%22%3A%5C%22v2.4325C29BA00E6470CBA54999680076F9%5C%22%2C%5C%22hasOnlyDefaultSalesChannel%5C%22%3Afalse%7D%22%7D%2C%7B%22key%22%3A%22locale%22%2C%22value%22%3A%22en-US%22%7D%5D%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientManyProductsQuery&operationHash=c0d7d2ae1d5aaae5d50eea683b389377c36fb57d&variables=%7B%22first%22%3A5%2C%22after%22%3A%220%22%2C%22sort%22%3A%22score_desc%22%2C%22term%22%3A%22%22%2C%22selectedFacets%22%3A%5B%7B%22key%22%3A%22buy%22%2C%22value%22%3A%2299995944%22%7D%2C%7B%22key%22%3A%22channel%22%2C%22value%22%3A%22%7B%5C%22salesChannel%5C%22%3A%5C%221%5C%22%2C%5C%22regionId%5C%22%3A%5C%22v2.4325C29BA00E6470CBA54999680076F9%5C%22%2C%5C%22hasOnlyDefaultSalesChannel%5C%22%3Afalse%7D%22%7D%2C%7B%22key%22%3A%22locale%22%2C%22value%22%3A%22en-US%22%7D%5D%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientProductQuery&operationHash=cedeb0c3e7ec1678400fe2ae930f5a79382fba1e&variables=%7B%22locator%22%3A%5B%7B%22key%22%3A%22id%22%2C%22value%22%3A%2299988211%22%7D%2C%7B%22key%22%3A%22channel%22%2C%22value%22%3A%22%7B%5C%22salesChannel%5C%22%3A%5C%221%5C%22%2C%5C%22regionId%5C%22%3A%5C%22v2.4325C29BA00E6470CBA54999680076F9%5C%22%2C%5C%22hasOnlyDefaultSalesChannel%5C%22%3Afalse%7D%22%7D%2C%7B%22key%22%3A%22locale%22%2C%22value%22%3A%22en-US%22%7D%5D%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
vars['alternateName1'] = jsonpath.query(
response.json(),
'$.data.product.image[0].alternateName'
)[0]
vars['sku1'] = jsonpath.query(response.json(), '$.data.product.sku')[0]
sleep(0.8)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientShippingSimulationQuery&operationHash=d6667f1de2a26b94b9b55f4b25d7d823f82635a0&variables=%7B%22items%22%3A%5B%7B%22id%22%3A%2299988211%22%2C%22quantity%22%3A1%2C%22seller%22%3A%221%22%7D%5D%2C%22postalCode%22%3A%2294102%22%2C%22country%22%3A%22USA%22%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
sleep(1.4)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientShippingSimulationQuery&operationHash=d6667f1de2a26b94b9b55f4b25d7d823f82635a0&variables=%7B%22items%22%3A%5B%7B%22id%22%3A%2299988211%22%2C%22quantity%22%3A2%2C%22seller%22%3A%221%22%7D%5D%2C%22postalCode%22%3A%2294102%22%2C%22country%22%3A%22USA%22%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
sleep(0.9)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientShippingSimulationQuery&operationHash=d6667f1de2a26b94b9b55f4b25d7d823f82635a0&variables=%7B%22items%22%3A%5B%7B%22id%22%3A%2299988211%22%2C%22quantity%22%3A3%2C%22seller%22%3A%221%22%7D%5D%2C%22postalCode%22%3A%2294102%22%2C%22country%22%3A%22USA%22%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientShippingSimulationQuery&operationHash=d6667f1de2a26b94b9b55f4b25d7d823f82635a0&variables=%7B%22items%22%3A%5B%7B%22id%22%3A%2299988211%22%2C%22quantity%22%3A4%2C%22seller%22%3A%221%22%7D%5D%2C%22postalCode%22%3A%2294102%22%2C%22country%22%3A%22USA%22%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
sleep(0.5)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientShippingSimulationQuery&operationHash=d6667f1de2a26b94b9b55f4b25d7d823f82635a0&variables=%7B%22items%22%3A%5B%7B%22id%22%3A%2299988211%22%2C%22quantity%22%3A3%2C%22seller%22%3A%221%22%7D%5D%2C%22postalCode%22%3A%2294102%22%2C%22country%22%3A%22USA%22%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientShippingSimulationQuery&operationHash=d6667f1de2a26b94b9b55f4b25d7d823f82635a0&variables=%7B%22items%22%3A%5B%7B%22id%22%3A%2299988211%22%2C%22quantity%22%3A2%2C%22seller%22%3A%221%22%7D%5D%2C%22postalCode%22%3A%2294102%22%2C%22country%22%3A%22USA%22%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientShippingSimulationQuery&operationHash=d6667f1de2a26b94b9b55f4b25d7d823f82635a0&variables=%7B%22items%22%3A%5B%7B%22id%22%3A%2299988211%22%2C%22quantity%22%3A1%2C%22seller%22%3A%221%22%7D%5D%2C%22postalCode%22%3A%2294102%22%2C%22country%22%3A%22USA%22%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
sleep(2.9)
response = http.post(
'https://starter.vtex.app/api/graphql?operationName=ValidateCartMutation&operationHash=534fae829675533052d75fd4aa509b9cf85b4d40',
`{"operationName":"ValidateCartMutation","operationHash":"534fae829675533052d75fd4aa509b9cf85b4d40","variables":{"session":{"addressType":null,"channel":"{\\"salesChannel\\":\\"1\\",\\"regionId\\":\\"v2.4325C29BA00E6470CBA54999680076F9\\",\\"hasOnlyDefaultSalesChannel\\":false}","country":"USA","currency":{"code":"USD","symbol":"\$"},"deliveryMode":null,"geoCoordinates":null,"locale":"en-US","person":null,"postalCode":"94102"},"cart":{"order":{"orderNumber":"9ee998dd4a464283acbb61df0fe44eac","acceptedOffer":[{"price":358.81,"listPrice":517.36,"seller":{"identifier":"1"},"quantity":1,"itemOffered":{"sku":"57815628","image":[{"alternateName":"facere","url":"https://storeframework.vtexassets.com/arquivos/ids/164897/perspiciatis.jpg?v=637752994369070000"}],"name":"blue","additionalProperty":[]}},{"price":306,"listPrice":489.27,"seller":{"identifier":"1"},"quantity":1,"itemOffered":{"sku":"30710027","image":[{"alternateName":"fugiat","url":"https://storeframework.vtexassets.com/arquivos/ids/181072/porro.jpg?v=637755520089470000"},{"alternateName":"praesentium","url":"https://storeframework.vtexassets.com/arquivos/ids/181069/sed.jpg?v=637755520080230000"},{"alternateName":"ea","url":"https://storeframework.vtexassets.com/arquivos/ids/181070/hic.jpg?v=637755520084470000"},{"alternateName":"illum","url":"https://storeframework.vtexassets.com/arquivos/ids/181071/veniam.jpg?v=637755520086800000"}],"name":"lime","additionalProperty":[]}},{"price":130,"listPrice":150,"seller":{"identifier":"1"},"quantity":1,"itemOffered":{"sku":"${vars['sku1']}","image":[{"alternateName":"${vars['alternateName1']}","url":"https://storeframework.vtexassets.com/arquivos/ids/190901/unsplash-headphone.jpg?v=637800115948430000"}],"name":"Leather","additionalProperty":[]}}]}}}}`,
{
headers: {
'content-type': 'application/json',
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
sleep(3.5)
response = http.post(
'https://starter.vtex.app/api/graphql?operationName=ValidateCartMutation&operationHash=534fae829675533052d75fd4aa509b9cf85b4d40',
`{"operationName":"ValidateCartMutation","operationHash":"534fae829675533052d75fd4aa509b9cf85b4d40","variables":{"session":{"addressType":null,"channel":"{\\"salesChannel\\":\\"1\\",\\"regionId\\":\\"v2.4325C29BA00E6470CBA54999680076F9\\",\\"hasOnlyDefaultSalesChannel\\":false}","country":"USA","currency":{"code":"USD","symbol":"\$"},"deliveryMode":null,"geoCoordinates":null,"locale":"en-US","person":null,"postalCode":"94102"},"cart":{"order":{"orderNumber":"9ee998dd4a464283acbb61df0fe44eac","acceptedOffer":[{"price":358.81,"listPrice":517.36,"seller":{"identifier":"1"},"quantity":1,"itemOffered":{"sku":"57815628","image":[{"alternateName":"facere","url":"https://storeframework.vtexassets.com/arquivos/ids/164897/perspiciatis.jpg?v=637752994369070000"}],"name":"blue","additionalProperty":[]}},{"price":130,"listPrice":150,"seller":{"identifier":"1"},"quantity":1,"itemOffered":{"sku":"${vars['sku1']}","image":[{"alternateName":"${vars['alternateName1']}","url":"https://storeframework.vtexassets.com/arquivos/ids/190901/unsplash-headphone.jpg?v=637800115948430000"}],"name":"Leather","additionalProperty":[]}}]}}}}`,
{
headers: {
'content-type': 'application/json',
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
sleep(1.3)
response = http.post(
'https://starter.vtex.app/api/graphql?operationName=ValidateCartMutation&operationHash=534fae829675533052d75fd4aa509b9cf85b4d40',
`{"operationName":"ValidateCartMutation","operationHash":"534fae829675533052d75fd4aa509b9cf85b4d40","variables":{"session":{"addressType":null,"channel":"{\\"salesChannel\\":\\"1\\",\\"regionId\\":\\"v2.4325C29BA00E6470CBA54999680076F9\\",\\"hasOnlyDefaultSalesChannel\\":false}","country":"USA","currency":{"code":"USD","symbol":"\$"},"deliveryMode":null,"geoCoordinates":null,"locale":"en-US","person":null,"postalCode":"94102"},"cart":{"order":{"orderNumber":"9ee998dd4a464283acbb61df0fe44eac","acceptedOffer":[{"price":130,"listPrice":150,"seller":{"identifier":"1"},"quantity":1,"itemOffered":{"sku":"${vars['sku1']}","image":[{"alternateName":"${vars['alternateName1']}","url":"https://storeframework.vtexassets.com/arquivos/ids/190901/unsplash-headphone.jpg?v=637800115948430000"}],"name":"Leather","additionalProperty":[]}}]}}}}`,
{
headers: {
'content-type': 'application/json',
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
sleep(0.8)
response = http.post(
'https://starter.vtex.app/api/graphql?operationName=ValidateCartMutation&operationHash=534fae829675533052d75fd4aa509b9cf85b4d40',
`{"operationName":"ValidateCartMutation","operationHash":"534fae829675533052d75fd4aa509b9cf85b4d40","variables":{"session":{"addressType":null,"channel":"{\\"salesChannel\\":\\"1\\",\\"regionId\\":\\"v2.4325C29BA00E6470CBA54999680076F9\\",\\"hasOnlyDefaultSalesChannel\\":false}","country":"USA","currency":{"code":"USD","symbol":"\$"},"deliveryMode":null,"geoCoordinates":null,"locale":"en-US","person":null,"postalCode":"94102"},"cart":{"order":{"orderNumber":"9ee998dd4a464283acbb61df0fe44eac","acceptedOffer":[{"price":130,"listPrice":150,"seller":{"identifier":"1"},"quantity":1,"itemOffered":{"sku":"${vars['sku1']}","image":[{"alternateName":"${vars['alternateName1']}","url":"https://storeframework.vtexassets.com/arquivos/ids/190901/unsplash-headphone.jpg?v=637800115948430000"}],"name":"Leather","additionalProperty":[]}}]}}}}`,
{
headers: {
'content-type': 'application/json',
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
sleep(5.6)
response = http.post(
'https://starter.vtex.app/api/graphql?operationName=ValidateCartMutation&operationHash=534fae829675533052d75fd4aa509b9cf85b4d40',
`{"operationName":"ValidateCartMutation","operationHash":"534fae829675533052d75fd4aa509b9cf85b4d40","variables":{"session":{"addressType":null,"channel":"{\\"salesChannel\\":\\"1\\",\\"regionId\\":\\"v2.4325C29BA00E6470CBA54999680076F9\\",\\"hasOnlyDefaultSalesChannel\\":false}","country":"USA","currency":{"code":"USD","symbol":"\$"},"deliveryMode":null,"geoCoordinates":null,"locale":"en-US","person":null,"postalCode":"94102"},"cart":{"order":{"orderNumber":"9ee998dd4a464283acbb61df0fe44eac","acceptedOffer":[{"price":130,"listPrice":150,"seller":{"identifier":"1"},"quantity":1,"itemOffered":{"sku":"${vars['sku1']}","image":[{"alternateName":"${vars['alternateName1']}","url":"https://storeframework.vtexassets.com/arquivos/ids/190901/unsplash-headphone.jpg?v=637800115948430000"}],"name":"Leather","additionalProperty":[]}}]}}}}`,
{
headers: {
'content-type': 'application/json',
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
response = http.post(
'https://starter.vtex.app/api/graphql?operationName=ValidateSession&operationHash=5696202828f9275216a445e316ebf516f168c506',
'{"operationName":"ValidateSession","operationHash":"5696202828f9275216a445e316ebf516f168c506","variables":{"session":{"addressType":null,"channel":"{\\"salesChannel\\":\\"1\\",\\"regionId\\":\\"v2.4325C29BA00E6470CBA54999680076F9\\",\\"hasOnlyDefaultSalesChannel\\":false}","country":"USA","currency":{"code":"USD","symbol":"$"},"deliveryMode":null,"geoCoordinates":null,"locale":"en-US","person":null,"postalCode":"94102"},"search":""}}',
{
headers: {
'content-type': 'application/json',
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientShippingSimulationQuery&operationHash=d6667f1de2a26b94b9b55f4b25d7d823f82635a0&variables=%7B%22items%22%3A%5B%7B%22id%22%3A%2299988211%22%2C%22quantity%22%3A1%2C%22seller%22%3A%221%22%7D%5D%2C%22postalCode%22%3A%2294102%22%2C%22country%22%3A%22USA%22%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
response = http.get(
'https://starter.vtex.app/api/graphql?operationName=ClientShippingSimulationQuery&operationHash=d6667f1de2a26b94b9b55f4b25d7d823f82635a0&variables=%7B%22items%22%3A%5B%7B%22id%22%3A%2299988211%22%2C%22quantity%22%3A1%2C%22seller%22%3A%221%22%7D%5D%2C%22postalCode%22%3A%2294102%22%2C%22country%22%3A%22USA%22%7D',
{
headers: {
dnt: '1',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
}
)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment