[英]Printing a list of Selenium Webdriver Elements returns serial number-like information; how can I make sense of this?
I'd like to find all the iframes on a particular page, so I can use Selenium Webdriver to navigate in and out of the iframes. 我想在特定页面上找到所有的iframe,因此我可以使用Selenium Webdriver导航进出iframe。
I used a query like 我使用了类似的查询
print(browser.find_elements_by_tag_name('iframe'))
and the command line returned: 并返回命令行:
C:\Python27\...path>file_name.py[<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="04088140-f-4b7d-849b-68bed36bc5c2", element="b78df9a9-b80f-4493-ac9f-b116d95ef5a6")>]
My question is: what does the form element="b78df9a9-b80f-4493-ac9f-b116d95ef5a6"
refer to? 我的问题是:
element="b78df9a9-b80f-4493-ac9f-b116d95ef5a6"
是什么意思? I understand it's the webdriver element, but how can one interpret the number itself? 我知道这是webdriver元素,但是如何解释数字本身呢? Furthermore, if I am to print out a list of the iframes by, say,
id
, how could I go about doing so? 此外,如果我要通过
id
来打印iframe列表,我该怎么做呢?
Thank you in advance. 先感谢您。
If you want to get id
of each iframe
element instead of its UUID
, you can do something like: 如果要获取每个
iframe
元素的id
而不是其UUID
,则可以执行以下操作:
frames = [frame.get_attribute('id') for frame in browser.find_elements_by_tag_name('iframe')]
Note, that not every iframe
could have an id
attribute ( iframe
without id
will be represent with None
value in frames
list) 请注意,并非每个
iframe
都可以具有id
属性(不带id
iframe
将在frames
列表中以None
值表示)
为什么不使用分配给元素的ID(在创建元素时给它命名),却使用其他方法(例如element_by_id或elements_by_class等)来获得特定的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.