0

I want to get these JavaScript values from web application.

var demoPlayResponse = {
 "winningPrizeIndex" : 1,
 "playMode"          : "NORMAL",
 "customerId"        : "pli",
 "gameVersion"       : "0-1-86",
 "gameId"            : "blue250k",
 "seed"              : 99
};
mws.GameModel.setPlayResponse(demoPlayResponse);
mws.GameModel.setGameMode(demoPlayResponse.playMode);

When I start the game I use Chrome development tools and I insert manually this code.

How I can get the values from Selenium?

Peter Penzov
  • 1,126
  • 134
  • 430
  • 808

1 Answers1

0

You can execute javascript code like this

((JavascriptExecutor) webDriver).executeScript(script);

For your use case, I would recommend making a function getDemoPlayResponse() that returns your variable and calling that function from Java class like this.

((JavascriptExecutor) webDriver).executeScript("return getDemoPlayResponse()");
Janar
  • 2,623
  • 1
  • 22
  • 32