Refused to execute inline script because of CSP

I am trying to execute a script that uses the .type into the login form or search bar but I keep getting this inline execution failed CSP message.

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' https://cdn.aibidia.com/pyramid/". Either the 'unsafe-inline' keyword, a hash ('sha256-3oCEUY6pDcTxOj/IfO7xFg9j//NlBbRX1KtksKnUAdo='), or a nonce ('nonce-...') is required to enable inline execution.  browser_source=security line_number=16 source=browser stacktrace="<nil>" url="https://func-aibidia-proxies-uat.azurewebsites.net/tpdoc/#/login"

This is my script

//import http from 'k6/http'
import { check } from 'k6'
import {browser} from 'k6/experimental/browser'

export const options = {
    scenarios: {
        ui:{
            executor: 'constant-vus',
            duration: '10s',
            vus: 1,
            options: {
            browser: {
                type: 'chromium',
              },
             
            }
          
          
          
    }
}
}

     
      
     

export default async function() {

    
    const page =  browser.newPage()

    try {

    
    await page.goto("https://func-aibidia-proxies-uat.azurewebsites.net/tpdoc/#/login")

    page.locator("//button[@class='a-button right a-primary-btn']").click()

    page.locator("#signInName").type("sagar.thetennis")
    page.locator('#password').type("hello")
   
    } finally {page.close()
    
    }

Hey @sagarthetennis10k

This error that you see is from the page output itself, is not an error from k6. You can differentiate that due to the source=browser “label” in the log line. If you open Chrome “manually”, go to the site under test and perform the same actions you should see the same error being reported in the console.

Still, in this case I believe this error is not impacting the actions performed in your test.

1 Like