Python + Selenium:从“ng-bind"获取跨度值 [英] Python + Selenium: get span value from "ng-bind"

查看:40
本文介绍了Python + Selenium:从“ng-bind"获取跨度值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有使用 chrome 访问页面的 Selenium 代码.现在在那个页面上,有这个 HTML;

So I have Selenium code that goes to a page using chrome. Now at that page, there is this HTML;

<span ngbind="pageData.Message">Heloooo</span>

如何使用 python 和 Selenium 获取值?所以只有Heloooo.谢谢!

How can I get the value using python and Selenium? So only the Heloooo. Thanks!

推荐答案

您可以使用以下 CSS Selector 来定位元素:

You can use the following CSS Selector for locating the element:

span[ngbind='pageData.Message']

代码:

element = driver.find_element_by_css_selector("span[ngbind='pageData.Message']")
print(element.text)  # Will print the "Heloooo" value.

希望对你有帮助!

这篇关于Python + Selenium:从“ng-bind"获取跨度值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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