Holmos.webtest.element.locator.LocatorFinder Maven / Gradle / Ivy
package Holmos.webtest.element.locator;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
/**
* @author 吴银龙(15857164387)*/
public class LocatorFinder {
private WebDriver driver;
private WebElement element;
private boolean isElementFinder;
public LocatorFinder(Object locatorFinder){
if(locatorFinder instanceof WebDriver){
this.driver=(WebDriver) locatorFinder;
this.isElementFinder=false;
}
else if(locatorFinder instanceof WebElement){
this.element=(WebElement) locatorFinder;
this.isElementFinder=true;
}
}
public WebElement findElement(By by){
if(this.isElementFinder){
return element.findElement(by);
}else
return driver.findElement(by);
}
public List findElements(By by){
if(this.isElementFinder){
return element.findElements(by);
}else
return driver.findElements(by);
}
}