问题
For example, HTML:
<input type="hidden" name="ie" value="utf-8">
this element don't have child element, when I use code:
List<WebElement> childElements = ele.findElements(By.xpath("./*"));
the program uses a very long time (about 30s) return a result. And the result size is right which is zero. So how can I resolve this problem? Thanks.
回答1:
As per the documentation findElements() method is affected by the implicit wait
duration in force at the time of execution. When implicitly waiting, findElements()
method will return as soon as there are more than 0 items in the found collection, or will return an empty list if the timeout is reached.
Possibly you have set implicitlyWait() somewhere before this block of code and configured as 30 seconds. Hence the TimeOut occurs at 30 seconds.
来源:https://stackoverflow.com/questions/55019463/why-does-selenium-get-the-child-elements-slowly