Home > Net >  How to add a key in the browser's 'Local Storage' using robot framework?
How to add a key in the browser's 'Local Storage' using robot framework?

Time:09-19

I was able to set a Cookie But When I checked login mechanism, I found that I should be setting key in the 'Local Storage'

Below is code for same:

Successful Login
   Create Session    loginsession  url=${base_url}     verify=true
   ${data}     Create dictionary   grant_type=password     username=${username}  password=${password}
   ${headers}  Create Dictionary     Content-Type=application/x-www-form-urlencoded     authorization=${authorization}
   ${resp}     POST On Session    loginsession     /oauth/token  params=${data}  headers=${headers}

   ${access_token}      Get Value From Json    ${resp.json()}      $.access_token
   Launch browser and maximize it   ${browser}
   Add Cookie   token   ${resp.json()}  domain=qa.mycrm.com
   Agent lands on My CRM Login Page
   Go To  https://qa.mycrm.com/dashboard/

I am seeking help on how can i set a key in browser's Local Storage

enter image description here

CodePudding user response:

Did you try importing Seleniumlibrary and use Execute Javascript?

Execute Javascript window.localStorage.setItem("abc", "SaHlOcAhIeBmy")

  • Related