Class CssSupportImpl

java.lang.Object
io.fluentlenium.core.css.CssSupportImpl
All Implemented Interfaces:
CssSupport

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 Details

    • CssSupportImpl

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

    • 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.

      Example:

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

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

      Example:

       @Test
       public void testMethod() {
            css().injectResource("/path/to/css/resource.css");
       }
       

      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
      Parameters:
      cssResourceName - css classpath resource to inject