0

I have a hard time finding a solution to my problem.

The scenario is this one: When I open my web app, I get in the browser Console an Array that I need to retrieve in my automation tests. I need this Array, because I need to do some operation based on it.

Is there a way using Selenium and Java to get this Array?

See the attached image for more info: enter image description here

Mihai C
  • 31
  • 4
  • How does the array get there? Do you output it to console from your webapp? – Docteur Feb 18 '20 at 09:28
  • 1
    Does [this](https://stackoverflow.com/questions/25431380/capturing-browser-logs-with-selenium-webdriver-using-java) answer your question? – Docteur Feb 18 '20 at 09:30
  • This is a QA testing environment and this console.log is send by the development team. I don't have to do anything to get it there, when I open the web application this Array is there – Mihai C Feb 18 '20 at 09:32
  • @Docteur if I use this: LogEntries logs = driver.manage().logs().get("browser"); I will only get the Logs, but not the Array. I tried this solution, but this Array is not seen by the LogEntries. – Mihai C Feb 18 '20 at 09:34
  • If on _open the web application this Array is there_, you will definitely get it within the DOM, search for it in the **Elements** tab. – undetected Selenium Feb 18 '20 at 09:36
  • @DebanjanB This looks to me more like a console.log() output than a DOM element. Mihai, have you added the capabilities to your webdriver? (Namely `LoggingPreferences logPrefs = new LoggingPreferences(); logPrefs.enable(LogType.BROWSER, Level.ALL); caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);`) – Docteur Feb 18 '20 at 09:40
  • @DebanjanB this Array is only in the Console tab, he is NOT displayed in DOM. If this Array was in DOM, my life would be so easy. This is why I don't have any idea how to get this. – Mihai C Feb 18 '20 at 09:42
  • @Docteur The query in the expanded form would have cleared all our doubts. – undetected Selenium Feb 18 '20 at 09:42
  • @Docteur I tried that solution, but I am still unable to get that Array. Even with this solution, I get only the Log entries. – Mihai C Feb 18 '20 at 09:55
  • Do you have access to the webapplication code? @MihaiC If so, could you post it in your question? Without that, it's going to be difficult to understand the problem – Docteur Feb 18 '20 at 09:56

0 Answers0