parent
a825aea600
commit
fe61540e84
|
@ -70,8 +70,8 @@ public class IfTextThread implements Callable<Boolean> {
|
|||
elements = ElementUtil.findElementsByText(context, driver, existValue);
|
||||
} catch (EnvironmentException | ParamMistakeException | NoSuchSessionException e) {
|
||||
throw e;
|
||||
}catch (Exception e) {
|
||||
logger.error("判断文本是否存在出错,文本内容:{}", text,e);
|
||||
} catch (Exception e) {
|
||||
logger.error("判断文本是否存在出错,文本内容:{}", text, e);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(elements)) {
|
||||
logger.info("找到元素{}个", elements.size());
|
||||
|
@ -85,12 +85,8 @@ public class IfTextThread implements Callable<Boolean> {
|
|||
}
|
||||
swipeNum--;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
logger.error("driver error!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("判断文本是否存在出错", e);
|
||||
}
|
||||
CommonUtils.handleSufExecuteWait(sufExecuteWait);
|
||||
return b;
|
||||
|
|
|
@ -1395,54 +1395,23 @@ public class ElementUtil {
|
|||
throw e;
|
||||
}
|
||||
WebElement webElement = null;
|
||||
try {
|
||||
while (swipeNum >= 0) {
|
||||
List<WebElement> elements = null;
|
||||
try {
|
||||
elements = driver.findElements(By.xpath(xpath));
|
||||
} catch (NoSuchSessionException e) {
|
||||
throw e;
|
||||
}
|
||||
logger.info("找到元素{}个", elements.size());
|
||||
if (!CollectionUtils.isEmpty(elements)) { //xpath找到了
|
||||
webElement = elements.get(0);
|
||||
} else { //xpath没找到
|
||||
if (swipeNum > 0) {
|
||||
ScreenUtil.standardSwipe(swipe, 2000, driver);
|
||||
}
|
||||
}
|
||||
swipeNum--;
|
||||
}
|
||||
} finally {
|
||||
while (swipeNum >= 0) {
|
||||
List<WebElement> elements = null;
|
||||
try {
|
||||
driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
logger.error("driver error");
|
||||
elements = driver.findElements(By.xpath(xpath));
|
||||
} catch (NoSuchSessionException e) {
|
||||
throw e;
|
||||
}
|
||||
logger.info("找到元素{}个", elements.size());
|
||||
if (!CollectionUtils.isEmpty(elements)) { //xpath找到了
|
||||
webElement = elements.get(0);
|
||||
} else { //xpath没找到
|
||||
if (swipeNum > 0) {
|
||||
ScreenUtil.standardSwipe(swipe, 2000, driver);
|
||||
}
|
||||
}
|
||||
swipeNum--;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -1643,12 +1612,6 @@ public class ElementUtil {
|
|||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error("查找控件异常", e);
|
||||
} finally {
|
||||
try {
|
||||
driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
logger.error("driver error");
|
||||
}
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
@ -1661,12 +1624,6 @@ public class ElementUtil {
|
|||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.error("查找控件异常", e);
|
||||
} finally {
|
||||
try {
|
||||
driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
logger.error("driver error");
|
||||
}
|
||||
}
|
||||
return exist;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue