You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm trying to pick up the number of DataLayer elements from a page and then loop through them and check their contents.
Using Serenity 2.3.6 with Java. My code:
`JavascriptExecutor js = (JavascriptExecutor) getDriver();
js.executeScript("console.clear()");
js.executeScript("console.log(window.dataLayer.length)");
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
desiredCapabilities.setCapability("goog:loggingPrefs", logPrefs);
LogEntries log = getDriver().manage().logs().get(LogType.BROWSER);
String consoleLog = log.getAll().toString();
String temp = consoleLog.substring(consoleLog.length() - 3);
String end = temp.substring(0, temp.length() - 1);
int dataLayerEntries = Integer.parseInt(end);'
The problem is that the logging doesn't pick up the js.executeScript stuff and still returns the console log before the clearing. I've tried adding to serenity.conf and serenity.properties the following 2 pieces of code respectively:
`webdriver {
logprefs {
driver = ALL
browser = ALL
}
Are you expecting Serenity or Selenium to perform this logging?
Selenium but I'm forced by BrowserStack integration to use the getDriver() method, instead of creating my own custom driver.
I've used the code below and it works correctly:
'ChromeOptions options = new ChromeOptions();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
options.setCapability("goog:loggingPrefs", logPrefs);
WebDriver driver = new ChromeDriver(options);'
Hello,
I'm trying to pick up the number of DataLayer elements from a page and then loop through them and check their contents.
Using Serenity 2.3.6 with Java. My code:
}'
chrome.switches=--enable-logging,--v=2,--no-sandbox,--log-level=0 chrome.capabilities.loggingPrefs={"driver":"ALL","browser":"ALL"}
Any ideas, suggestions?
The text was updated successfully, but these errors were encountered: