Hello there, I am using k6 browser module for testing a web application. I have already created an end-to-end test script that requires to login to the web page using OTP which has to be retrieved from the gmail. We are using Google OAuth2 API to fetch the OTP from mail and have already created script to retrieve the OTP. I am trying to import that script in my k6 load test script to login, but receiving error as
ERRO[0000] GoError: The moduleSpecifier "googleapis" couldn't be recognised as something k6 supports.
at go.k6.io/k6/js.(*requireImpl).require-fm (native)
at file:///C:/Users/vignesh.t/Desktop/Test%20script/OAuth/getCode.js:1:0(5)
at go.k6.io/k6/js.(*requireImpl).require-fm (native)
at file:///C:/Users/vignesh.t/Desktop/Test%20script/script.js:81:0(23) hint="script exception"
How can I make the googleapis supportable in my k6 load test script? Is there any way around? It would be helpful if someone can help me with this.
So I am using the http.get() to access the mail. But this isn’t working, I am getting status code 401. The same logic is working in postman to get a response. Why isn’t it working here?It would be much helpful if someone can solve this problem.
Ok, so firstly headers is part of params in the get API.
Secondly it might be worth taking a look at this library to help you build the url. The reason i’m suggesting this is that there is no q field in params.
I was able to get the mail body using the following code where I only pass two parameters inside the http.get() method. As per the documentation we can only pass two parameters inside http.get() method.