Why does Selenium get the child elements slowly

可紊 提交于 2021-01-29 02:13:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!