为什么Selenium获取子元素慢 [英] Why does Selenium get the child elements slowly

查看:45
本文介绍了为什么Selenium获取子元素慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,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("./*"));

程序使用了很长时间(大约30s)返回一个结果.结果大小是正确的,为零.那么我该如何解决这个问题呢?谢谢.

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.

推荐答案

根据文档 findElements() 方法受隐式等待持续时间的影响.执行.隐式等待时,findElements() 方法会在找到的集合中超过 0 项时立即返回,如果超时则返回空列表.

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.

可能您已经设置了 implicitlyWait() 在此代码块之前的某处,并配置为 30 秒.因此,TimeOut 发生在 30 秒.

Possibly you have set implicitlyWait() somewhere before this block of code and configured as 30 seconds. Hence the TimeOut occurs at 30 seconds.

这篇关于为什么Selenium获取子元素慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆