<commit_before>package com.redheap.selenium;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;


public abstract class AdfConditions {

    private AdfConditions() {
    }

    public static ExpectedCondition<Boolean> clientSynchedWithServer() {
        // return false if AdfPage object and functions do not exist
        // if they do exist return true if page is fully loaded and ready or reason why this is not completed yet
        return javascriptExpressionTrue("typeof AdfPage !== 'undefined' && " +
                                        "typeof AdfPage.PAGE !== 'undefined' && " +
                                        "typeof AdfPage.PAGE.isSynchronizedWithServer === 'function' && " +
                                        "(AdfPage.PAGE.isSynchronizedWithServer() || " +
                                        "(typeof AdfPage.PAGE.whyIsNotSynchronizedWithServer === 'function' && " +
                                        "AdfPage.PAGE.whyIsNotSynchronizedWithServer()))");
    }

    public static ExpectedCondition<Boolean> javascriptExpressionTrue(final String jsExpression) {
        return new ExpectedCondition<Boolean>() {
            @Override
            public Boolean apply(final WebDriver driver) {
                JavascriptExecutor jsDriver = (JavascriptExecutor) driver;
                Object result = jsDriver.executeScript("return " + jsExpression);
                System.out.println("js result: " + result + " [" + jsExpression + "]");
                return Boolean.TRUE.equals(result);
            }
        };
    }

}<commit_msg>java logging is so much better than System.out.println<commit_after>package com.redheap.selenium;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;


public abstract class AdfConditions {

    private static final Logger logger = Logger.getLogger(AdfConditions.class.getName());

    private AdfConditions() {
    }

    public static ExpectedCondition<Boolean> clientSynchedWithServer() {
        // return false if AdfPage object and functions do not exist
        // if they do exist return true if page is fully loaded and ready or reason why this is not completed yet
        return javascriptExpressionTrue("typeof AdfPage !== 'undefined' && " +
                                        "typeof AdfPage.PAGE !== 'undefined' && " +
                                        "typeof AdfPage.PAGE.isSynchronizedWithServer === 'function' && " +
                                        "(AdfPage.PAGE.isSynchronizedWithServer() || " +
                                        "(typeof AdfPage.PAGE.whyIsNotSynchronizedWithServer === 'function' && " +
                                        "AdfPage.PAGE.whyIsNotSynchronizedWithServer()))");
    }

    public static ExpectedCondition<Boolean> javascriptExpressionTrue(final String jsExpression) {
        return new ExpectedCondition<Boolean>() {
            @Override
            public Boolean apply(final WebDriver driver) {
                JavascriptExecutor jsDriver = (JavascriptExecutor) driver;
                String js = "return " + jsExpression;
                logger.log(Level.FINER, "executing condition javascript: {0}", js);
                Object result = jsDriver.executeScript(js);
                logger.log(Level.FINER, "js result: {0}", result);
                return Boolean.TRUE.equals(result);
            }
        };
    }

}
{'fraction_non_alphanumeric': 0.09341416368145494, 'fraction_numerical': 0.0005511160099200882, 'mean_word_length': 2.1537793223284103, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4150614', 'n_tokens_mistral': 894, 'n_tokens_neox': 847, 'n_words': 213}