This project focuses on automation of multi-level shadow root dom using java selenium. You can embed this plugin in your java selenium project.
This release is done to support Shadow library to be used with Selenium 4. Shadow 0.1.5 is tested and verified with Selenium 4.16.1
Feature: Flexibility to use any depth levels of CSS and XPath.
Implementation of Page Factory to find elements using css and xpath.
PageFactory.initElements(new ElementFieldDecorator(new DefaultElementLocatorFactory(driver), this)
.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);
}
//...
}
Fixed issues #33 #25 and added enhancement #28
fixed XPath issues.
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
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 #16 specific issue for selectors with more than 2 levels.
Now all methods for finding web elements will implement implicit waits internally. If implicitWait is once set it will work for following methods.
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).