From 9faee56b08a882fe7ffbedea7a7f481eb7746fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E5=AE=87=E7=90=A6?= <465645774@qq.com> Date: Mon, 7 Dec 2020 07:59:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=85=83=E7=B4=A0=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E5=90=8E=EF=BC=8C=E4=B8=AA=E6=95=B0=E8=B6=85=E5=87=BA?= =?UTF-8?q?=E9=99=90=E5=88=B6=E6=97=B6=E6=8A=9B=E5=87=BA=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E8=B6=8A=E7=95=8C=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/pres/auxiliary/work/selenium/element/Element.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/pres/auxiliary/work/selenium/element/Element.java b/src/main/java/pres/auxiliary/work/selenium/element/Element.java index acf55e5..65a509a 100644 --- a/src/main/java/pres/auxiliary/work/selenium/element/Element.java +++ b/src/main/java/pres/auxiliary/work/selenium/element/Element.java @@ -57,6 +57,10 @@ public class Element { throw new NoSuchElementException("指定的元素下标值不存在,当前元素集合个数:" + abstractBy.elementList.size()); } + if (index >= abstractBy.elementList.size()) { + throw new NoSuchElementException(String.format("重置元素后,指定的元素下标值(%d)不存在,当前元素集合个数:%d", index, abstractBy.elementList.size())); + } + //判断当前类中存储的元素数据类对象是否与abstractBy中存储的数据类对象一致,若不一致,则重新获取元素 if (!this.elementData.getName().equals(abstractBy.elementData.getName())) { againFindElement();