I have a JavaScript Object that needs to be set using Selenium WebDriver.
var examplePlayResponse = {
"prizeIndex" : 1,
"mode" : "NORMAL",
"id" : "abc123",
"version" : "1.0",
"gameCode" : "xyz789",
"randomSeed" : 42
};
mws.GameModel.setPlayResponse(examplePlayResponse);
mws.GameModel.setGameMode(examplePlayResponse.mode);
Is there a way to achieve this through Selenium?
I attempted the following method:
public void performTest()
{
driver = BrowserFactory.getDriver("chrome", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");
driver.get("http://example.com");
WebDriverWait waitPage = new WebDriverWait(driver, 20);
((JavascriptExecutor) driver).executeScript("return getExamplePlayResponse()");
}