katalon stale element reference: element is not attached to the page document

import java.util.logging.Logger

import com.kms.katalon.core.webui.driver.DriverFactory

public Boolean isDisplay(TestObject to, final String text) {

String path = to.getSelectorCollection().get(SelectorMethod.XPATH)

Logger logger = Logger.getLogger("InfoLogging");

logger.info("wait add to cart mes display");

boolean result = false;

int attempts = 0;

while (attempts < 5) {

try {

attempts++;

logger.info("scan" + attempts + "time(s)");

result = new WebDriverWait(driver, 30)

.until(new ExpectedCondition<Boolean>() {

public Boolean apply(WebDriver driver) {

return driver.findElement(By.xpath(path)).getText().contains(text);

}

});

logger.info("scan end");

return true;

} catch (Exception e) {

e.printStackTrace();

}

}

return result;

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容