Open uttarwarsandesh33 opened 4 years ago
Hello uttarwarsandesh33, your questions has little to do with this package and answers can be eaisly found on google, but let me help you:
API doesn't provide a way to directly read/write the local storage, but it can be done with execute_script:
let value = await driver.executeScript("return window.localStorage.getItem(arguments[0]);", key)
or
driver.executeScript("window.localStorage.setItem(arguments[0], arguments[1]);", key, value)
The same way as above - by manipulating it with executeScript.
Due to many possible configurations the best way would be to create customDriver.js file in your home directory:
'use strict';
var { Builder } = require('selenium-webdriver');
/**
const screen = { width: 640, height: 480 };
let driver = new Builder() .forBrowser('chrome') .setChromeOptions(new chrome.Options().headless().windowSize(screen)) .setFirefoxOptions(new firefox.Options().headless().windowSize(screen)) .build(); }
and run it with:
**node ./node_modules/selenium-cucumber-es6/index.js -s ./step-definitions -b customDriver.js**
getting this error while using let value = await driver.executeScript("return window.localStorage.getItem(arguments[0]);", key)
JavascriptError: SecurityError: The operation is insecure. at Object.throwDecodedError
I want to check localStorage in test how Can I do that?
Am I able to access the window object?
How can run this with Headless
Thanks