Access to variables from console log

My app has a store (a la redux, ngrx, vuex, etc). After accessing a url, I’d like to check the values of certain properties of the store object. I currently have a hovering debug div that has buttons that console log these properties. Is there a way for Katalon to access what gets logged to the console (or maybe another nifty way to check changes to my stores after hitting various url addresses) ?

Benjamin McFerren said:

My app has a store (a la redux, ngrx, vuex, etc). After accessing a url, I’d like to check the values of certain properties of the store object. I currently have a hovering debug div that has buttons that console log these properties. Is there a way for Katalon to access what gets logged to the console (or maybe another nifty way to check changes to my stores after hitting various url addresses) ?

Hi Ben,

Would you please try to your best ability explain what are you trying to achieve? The more details the better for everyone to help you find the answer.

Thanks for choosing Katalon Studio,
Liam

Hi Liam - I am trying to access state variables from my SPA application. After a bunch of research, I ended up using the window global namespace to store an object in my button click handler function: myFunc() { window[ “seleniumGlobal” ] = { foo: “bagaloo” }; } Then, in my selenium script I use JavascriptExecutor to access this variable object:

WebUI.click(findTestObject(‘Page_button (1)/span_dump NGRX store’))

WebDriver driver = DriverFactory.getWebDriver()

JavascriptExecutor js = (JavascriptExecutor)driver;

Object result = js.executeScript(“return seleniumGlobal”);

println(result.foo);

Thank you for your help and time Liam :slight_smile: Please let me know if there is a better way to achieve access to state variables from my SPA application

I’m not sure if it’s exactly what you’re looking for, but you can write out values to the Katalon log files. I use the Warning log as almost nothing else gets written there. It would be a change to your println(result.foo); line.

import com.kms.katalon.core.logging.KeywordLogger as KeywordLogger

KeywordLogger log = new KeywordLogger()
log.logWarning(‘The value is:=’ + results.foo)
Your text and value will then appear in the Warning Log, separated out from all the other items. Much easier to read.

Perhaps I understand what @Benjamin_McFerren is trying to achieve.
And I want the same.

Normale I go to Developer tools from my browser and type in DataLayer to check Google Analytics events.
Now I want to solve this manual work with Katalon.

Any hints how to access the dataLayer?