从没有文本值的角度元素获取文本

2024-05-13 22:59:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我在一个简单的表中遇到了一个文本字段,我要检查/提取的文本不是元素中任何值的一部分。在

{{and{cd2>使用的值来获得{。一切都会回来

AttributeError: 'WebElement' object has no attribute 'get_text'

这并不奇怪,因为元素中没有真正的值。这是一个基于AngularJS的网站。在

元素看起来像这样,里面的文字是“法国”:

<span class="keyword-autocomplete-container" model="flavor.subregion" keyword-autocomplete="subregion" filter="{ancestorId: flavor.regionId || flavor.countryId}" with-aliases="true" replace-alias="true">  <input ng-model="localModel" ng-disabled="ngDisabled" mass-autocomplete-item="createOptions()" ng-keypress="onKeyPressed($event)" class="ng-pristine ng-valid ng-touched" autocomplete="off"></span>

对于这些孩子:

^{pr2}$

我指向那个元素的选择器工作得很好。我可以键入一些文本或单击它没有问题。任何人都可以帮助如何从这样的元素读取文本?非常感谢。在


Tags: and文本true元素modelngautocompletekeyword