WebElement
에서 Findby
유형 및 문자열을 얻으려면 어떻게해야합니까?WebElement에서 Findby 유형 및 문자열을 가져 오는 방법
나는 presenceOfElementLocated() 함수에서 사용할 Web 요소를받을 수있는 자체 내장 webDriverWait
함수를 사용하고 있습니다. WebElement 정의
@FindBy(xpath = "//div[@id='calendar-1234']")
private WebElement calander;
첫 번째는 작성자 사용하고 좋아하고있다
기능 설명 webDriverWaitFor 두 : 두 번째 용도는 두 번째 사용
public void webDriverWaitFor(WebDriver driver, By by) throws ElementLocatorException {
try{
(new WebDriverWait(driver, 5))
.until(ExpectedConditions.presenceOfElementLocated(by));
}
catch (Exception e) {
throw new ElementLocatorException(by);
}
}
webElement WebElement By 유형 및 문자열을 가져 오려고합니다. 이 implimintation 잘되지 않습니다 : By.id (webElement.getAttribute ("ID"))
public void webDriverWaitFor(WebDriver driver, WebElement webElement) throws ElementLocatorException {
try{
(new WebDriverWait(driver, 5))
.until(ExpectedConditions.presenceOfElementLocated( By.id(webElement.getAttribute("id"))));
}
catch (Exception e) {
throw new ElementLocatorException(By.id(webElement.getAttribute("id")));
}
}
나는 다음과 같은 구현할 수있을 것입니다 방법
?
webDriverWaitFor(driver, calander);
pagefactory를 사용하여 어떻게 custom isElementPresent를 쓸 수 있습니까? pagefactory 없이는는 다음과 같이 기록됩니다 는'{ \t \t \t 경우 (driver.findElements (로케이터) 크기는()> 0) { \t \t \t \t 반환 사실을 시도; \t \t \t} else else \t \t \t \t false; \t \t} \t \t 캐치 (예외 전자) {거짓 \t \t \t 반환; \t \t} – paul