简体   繁体   English

打印Selenium Webdriver Elements列表将返回类似序列号的信息; 我该如何理解?

[英]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.

相关问题 在Python 3中,如何创建类似数字的对象? - in Python 3, how to create a number-like object? 如何列出硒元素? - How can I make a list of elements Selenium? Selenium webdriver 从 find_elements_by_X 返回空列表 - Selenium webdriver returns empty list from find_elements_by_X Python Selenium:我该如何处理[<selenium.webdriver.remote.webelement.webelement (session.....)> ]</selenium.webdriver.remote.webelement.webelement> - Python Selenium: How can I deal with results like [<selenium.webdriver.remote.webelement.WebElement (session.....)>] 如何使计数函数返回列表中的元素数 - How to make a counting function that returns the number of elements in a list 如何获取使用 Selenium WebDriver 和 Python 找到的元素数量? - How to get the number of elements found using Selenium WebDriver with Python? 如何使用 Python 正确遍历 Selenium Webdriver 中的 Web 元素列表? - How do I properly iterate through a list of web elements in Selenium Webdriver using Python? 类似Python的数字类会记住算术运算吗? - Python number-like class that remembers arithmetic operations? 如何使用 selenium/webdriver 打开网站? - How can I open websites with selenium/webdriver? 为什么我不能对页面中的多个元素使用 WebDriver Wait for Selenium Webdriver? - Why can't I use WebDriver Wait for Selenium Webdriver for multiple elements in a page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM