Class CssSupportImpl

  • All Implemented Interfaces:

    public class CssSupportImpl
    extends Object
    implements CssSupport
    Features related to CSS loaded in the active page.

    There is a retry logic trying to inject the CSS, using an underlying JavascriptExecutor, maximum MAX_SCRIPT_EXECUTION_RETRY_COUNT times in case it fails, and waits for EXPLICIT_WAIT_PERIOD between each try.

    The injection logic is stored in INJECTOR_JS_PATH.

    Currently neither the max retry count nor the amount of wait between each try is configurable.

    • Constructor Detail

      • CssSupportImpl

        public CssSupportImpl​(JavascriptControl javascriptControl,
                              AwaitControl awaitControl)
        Creates a new implementation of css support.
        javascriptControl - javascript control for the injection
        awaitControl - await control for waiting between injection retries
    • Method Detail

      • inject

        public void inject​(String cssText)
        Description copied from interface: CssSupport
        Inject CSS into active page.

        Additional escaping might be necessary depending on in what form the source if provided.


         public void testMethod() {
              css().inject("#location {display: none}");
              css().inject("#location {\ndisplay: none\n}");
        Specified by:
        inject in interface CssSupport
        cssText - css source to inject
      • injectResource

        public void injectResource​(String cssResourceName)
        Inject CSS classpath resource into active page.


         public void testMethod() {

        This implementation doesn't inject the provided resource as an external CSS <link> tag into the document, rather it injects the content of the resource itself.

        Specified by:
        injectResource in interface CssSupport
        cssResourceName - css classpath resource to inject