Class SeleniumLocator

java.lang.Object
dev.comfast.cf.CfAbstractLocator
dev.comfast.cf.se.SeleniumLocator
All Implemented Interfaces:
CfLocator
Direct Known Subclasses:
FoundElement

public class SeleniumLocator extends CfAbstractLocator implements CfLocator
  • Constructor Details

    • SeleniumLocator

      public SeleniumLocator(String selector, Object... params)
    • SeleniumLocator

      protected SeleniumLocator(SelectorChain chain)
  • Method Details

    • $

      public CfLocator $(String selector, Object... params)
      Description copied from interface: CfLocator
      get sub-locator related to current one
      Specified by:
      $ in interface CfLocator
      Returns:
      Cfloctor
    • getAttribute

      public String getAttribute(String name)
      Specified by:
      getAttribute in interface CfLocator
      Returns:
      javascript attribute of element
    • getCssValue

      public String getCssValue(String name)
      Specified by:
      getCssValue in interface CfLocator
      Parameters:
      name - eg. color, opacity, etc.
      Returns:
      css value of given name
    • getTagName

      public String getTagName()
      Specified by:
      getTagName in interface CfLocator
      Returns:
      html tag name
    • exists

      public boolean exists()
      Specified by:
      exists in interface CfLocator
      Returns:
      true if element exists in DOM
    • isDisplayed

      public boolean isDisplayed()
      Specified by:
      isDisplayed in interface CfLocator
      Returns:
      true if element is visible, not throw if element not found - just return false
    • tap

      public void tap()
      Description copied from interface: CfLocator
      Tap gesture on element
      Specified by:
      tap in interface CfLocator
    • click

      public void click()
      Description copied from interface: CfLocator
      Click on element
      Specified by:
      click in interface CfLocator
    • focus

      public void focus()
      Description copied from interface: CfLocator
      Focus on element using JS
      Specified by:
      focus in interface CfLocator
    • hover

      public void hover()
      Description copied from interface: CfLocator
      Hover mouse on element
      Specified by:
      hover in interface CfLocator
    • dragTo

      public void dragTo(CfLocator target)
      Description copied from interface: CfLocator
      Drag current element onto other element
      Specified by:
      dragTo in interface CfLocator
    • setValue

      public void setValue(String value)
      Description copied from interface: CfLocator
      Generic set value of element. Should work on input, textarea, select, etc.
      Specified by:
      setValue in interface CfLocator
      Parameters:
      value - to set
    • setChecked

      public void setChecked(boolean state)
      Description copied from interface: CfLocator
      Check/uncheck checkbox
      Specified by:
      setChecked in interface CfLocator
      Parameters:
      state - true- check, false - uncheck
    • clear

      public void clear()
      Description copied from interface: CfLocator
      Clear given input/textarea/select/checkbox
      Specified by:
      clear in interface CfLocator
    • type

      public void type(String keys)
      Description copied from interface: CfLocator
      Type keys into element
      Specified by:
      type in interface CfLocator
      Parameters:
      keys - keyboard input, can use special keys in format: {Ctrl}, {Ctrl+Shift+L}, {Shift+some text} etc.
    • count

      public int count()
      Specified by:
      count in interface CfLocator
      Returns:
      number of elements found by locator
    • nth

      public CfLocator nth(int nth)
      Description copied from interface: CfLocator
      nth element found by locator
      Specified by:
      nth in interface CfLocator
      Parameters:
      nth - index starting of 1
      Returns:
      CfLocator
    • executeJs

      public Object executeJs(String script, Object... args)
      Description copied from interface: CfLocator
      Executes JavaScript code, where "this" is current element
      Specified by:
      executeJs in interface CfLocator
      Parameters:
      script - JS Code
      args - arguments for JS code
      Returns:
      result of JS code
    • map

      public <T> List<T> map(Function<CfLocator,T> func)
      Description copied from interface: CfLocator
      Does mapping against each element found by locator
      Specified by:
      map in interface CfLocator
      Type Parameters:
      T - mapping result type
      Parameters:
      func - mapping function, eg. locator -> locator.getText()
      Returns:
      list of mapped values
    • doExecuteJs

      protected Object doExecuteJs(String script, Object... args)
    • find

      protected org.openqa.selenium.WebElement find()
    • tryFind

      protected Optional<org.openqa.selenium.WebElement> tryFind()