fix:通用组件库

1.删除部分finally中将驱动的隐式等待去掉。
master
李杰应 2024-09-25 20:17:22 +08:00
parent a825aea600
commit fe61540e84
2 changed files with 18 additions and 65 deletions

View File

@ -70,8 +70,8 @@ public class IfTextThread implements Callable<Boolean> {
elements = ElementUtil.findElementsByText(context, driver, existValue); elements = ElementUtil.findElementsByText(context, driver, existValue);
} catch (EnvironmentException | ParamMistakeException | NoSuchSessionException e) { } catch (EnvironmentException | ParamMistakeException | NoSuchSessionException e) {
throw e; throw e;
}catch (Exception e) { } catch (Exception e) {
logger.error("判断文本是否存在出错,文本内容:{}", text,e); logger.error("判断文本是否存在出错,文本内容:{}", text, e);
} }
if (!CollectionUtils.isEmpty(elements)) { if (!CollectionUtils.isEmpty(elements)) {
logger.info("找到元素{}个", elements.size()); logger.info("找到元素{}个", elements.size());
@ -85,12 +85,8 @@ public class IfTextThread implements Callable<Boolean> {
} }
swipeNum--; swipeNum--;
} }
} finally {
try {
driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
} catch (Exception e) { } catch (Exception e) {
logger.error("driver error!"); logger.error("判断文本是否存在出错", e);
}
} }
CommonUtils.handleSufExecuteWait(sufExecuteWait); CommonUtils.handleSufExecuteWait(sufExecuteWait);
return b; return b;

View File

@ -1395,7 +1395,6 @@ public class ElementUtil {
throw e; throw e;
} }
WebElement webElement = null; WebElement webElement = null;
try {
while (swipeNum >= 0) { while (swipeNum >= 0) {
List<WebElement> elements = null; List<WebElement> elements = null;
try { try {
@ -1413,36 +1412,6 @@ public class ElementUtil {
} }
swipeNum--; swipeNum--;
} }
} finally {
try {
driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
} catch (Exception e) {
logger.error("driver error");
}
}
/* SessionId sessionId = driver.getSessionId();
logger.debug("当前driver的sessionId为{}", sessionId);
try {
webElement = submit.get(waitTimeout, TimeUnit.SECONDS);
logger.info("拿到元素:{}", webElement);
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof NoSuchSessionException) {
logger.error("driver失效了。。。。");
NoSuchSessionException nsse = (NoSuchSessionException) cause;
throw nsse;
}
} catch (Exception e) {
logger.error("xpath找元素出错", e);
xpathThread.kill();
} finally {
try {
driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
} catch (Exception e) {
logger.error("driver error");
}
}*/
return webElement; return webElement;
} }
@ -1643,12 +1612,6 @@ public class ElementUtil {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
logger.error("查找控件异常", e); logger.error("查找控件异常", e);
} finally {
try {
driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
} catch (Exception e) {
logger.error("driver error");
}
} }
return point; return point;
} }
@ -1661,12 +1624,6 @@ public class ElementUtil {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
logger.error("查找控件异常", e); logger.error("查找控件异常", e);
} finally {
try {
driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
} catch (Exception e) {
logger.error("driver error");
}
} }
return exist; return exist;
} }