Browser testing getting below error

Continuing the discussion from Can't run browser tests with K6_BROWSER_ENABLED=true k6 run script.js:

PS C:\K6-Scripts\specs> $env:K6_BROWSER_ENABLED=true ; k6 run .\BrowserTest.js efault
true : The term ‘true’ is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path
is correct and try again.
At line:1 char:25

  • $env:K6_BROWSER_ENABLED=true ; k6 run .\BrowserTest.js

  •                     ~~~~
    
    • CategoryInfo : ObjectNotFound: (true:String) , CommandNotFoundException

    • FullyQualifiedErrorId : CommandNotFoundException

      /\      |‾‾| /‾‾/   /‾‾/
      

    /\ / \ | |/ / / /
    / / \ | ( / ‾‾
    / \ | |\ \ | (‾) |
    / __________ \ |__| _\ ____/ .io

    execution: local
    script: .\BrowserTest.js
    output: -

    scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
    * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)

ERRO[0000] Uncaught (in promise) TypeError: Cannot read property ‘launch’ of undefined or null
at browserTest (file:///C:/K6-Scripts/specs/BrowserTest.js:6:18(7)) executor=per-vu-iterations scenario=default

 data_received........: 0 B 0 B/s
 data_sent............: 0 B 0 B/s
 iteration_duration...: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
 iterations...........: 1   0/s

running (00m00.0s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 00m00.0s/10m0s 1/1 iters, 1 per VU

------------------------------ find the program —

import {chromium} from ‘k6/experimental/browser’
import {check} from ‘k6’

export default async function browserTest(){

const browser=chromium.launch({headless:false})
const page= browser.newPage()

await page.goto('https://stage-lcm.ehs.edison.gehealthcare.com/')

const userName=page.locator("//input[@id='usernameUserInput']")
text.type('sb_test_lcm2@hc.ge.com');

check (page, {

    'headerOfthePage' : page =>page.locator("//legend[@class='heading-30 u-mb+ u-pb text-align--center noMobileMarginAuto noMobilePadding']").isVisible()===true

})

page.close(
    browser.close()
)

}

Hi,

Have you tried wrapping true within single-quotes like this 'true' as suggested in this comment.

PS: Could you please format your question, as it’s hard to see the problem? Is the question about the usage of K6_BROWSER_ENABLED on Windows or something else?

Thanks!

Getting the below error - browser also not launching -
ERRO[0000] Uncaught (in promise) TypeError: Cannot read property ‘launch’ of undefined or null
at browserTest (file:///C:/K6-Scripts/specs/BrowserTest.js:5:20(7)) executor=per-vu-iterations scenario=default

I am using window… and I used. the below, and its fine

PS C:\K6-Scripts\specs> set K6_BROWSER_ENABLED=true

this is the issue

need to configure anywhere - “launch” because I am unable to launch the browser.

We no longer use launch. Please see this migration document to migrate to the new browser API.

I hope this helps.