Releases: sukgu/shadow-automation-selenium
Support for Selenium 4
Feature: Flexibility to use any depth levels of css and xpath.
Feature: Flexibility to use any depth levels of CSS and XPath.
Implementation of Page Factory to find elements using css and xpath.
Implementation of Page Factory to find elements using css and xpath.
PageFactory:
- @FindElementBy annotation can be used with PageFactory model to find elements based on css_selector or xpath.
- To achieve this you will need to modify page initialization method as
PageFactory.initElements(new ElementFieldDecorator(new DefaultElementLocatorFactory(driver), this)
. - For more example on PageFactory see this page.
PageFactory Example:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.DefaultElementLocatorFactory;
import io.github.sukgu.support.ElementFieldDecorator;
import io.github.sukgu.support.FindElementBy;
public class LocalTestPage {
WebDriver driver;
@FindElementBy(css = "#container")
WebElement container;
@FindBy(css = "#h3")
WebElement h3;
@FindBy(css = "#h3")
List<WebElement> allH3;
@FindElementBy(css = "#inside")
List<WebElement> insides;
@FindElementBy(xpath = "//body")
WebElement bodyByXPath;
@FindElementBy(xpath = "//body//div[1]")
WebElement divByIndex;
public LocalTestPage(WebDriver driver) {
this.driver = driver;
ElementFieldDecorator decorator = new ElementFieldDecorator(new DefaultElementLocatorFactory(driver));
// need to use decorator if you want to use @FindElementBy in your PageFactory model.
PageFactory.initElements(decorator, this);
}
//...
}
Added Enhancements & Fixed issues
Patch release with issues fixed.
fixed XPath issues.
Implementation of XPath as selector to find elements.
Added the following methods to use XPath:
WebElement findElementByXPath(String XPath)
: use this method if want a single element from DOM
List<WebElement> findElementsByXPath(String XPath)
: use this if you want to find all elements from DOM
WebElement findElementByXPath(WebElement parent, String XPath)
: use this if you want to find a single element from the parent object DOM
List<WebElement> findElementsByXPath(WebElement parent, String XPath)
: use this if you want to find all elements from parent object DOM
Added highlight methods:
void highlight(WebElement element, String color, Integer timeInMiliSeconds)
: highlight method.
void highlight(WebElement element)
: highlight method highlight in red color.
For more information follow the link
Fixed core library issue.
Fixed core library #16 specific issue for selectors with more than 2 levels.
Implemented implicit wait for other methods
Now all methods for finding web elements will implement implicit waits internally. If implicitWait is once set it will work for following methods.
- WebElement findElement(String cssSelector)
- WebElement findElement(WebElement parent, String cssSelector)
- List findElements(String cssSelector)
- List findElements(WebElement parent, String cssSelector)
- WebElement getShadowElement(WebElement parent,String selector)
- List getAllShadowElement(WebElement parent,String selector)
- WebElement getParentElement(WebElement element)
- List getChildElements(WebElement parent)
- List getSiblingElements(WebElement element)
- WebElement getSiblingElement(WebElement element, String selector)
Added Implicit and Explicit Wait
This feature will add wait methods on shadow objects
Currently, we are not able to use selenium implicit and explicit waits on shadow objects. This feature will methods like selenium that will work for shadow objects.
Additional context
After this fix user will be able to use shadow objects waits in the same way they use selenium waits and this will work for both normal DOM elements and shadow DOM elements.
Added 2 methods setImplictWait(int seconds) and setExpilictWait(int seconds, int pollingTime).