gpt4 book ai didi

python - 无法在Python中使用selenium在Angular JS中定位元素(文本字段)

转载 作者:太空宇宙 更新时间:2023-11-03 16:28:39 29 4
gpt4 key购买 nike

我在将 key 发送到用 Angular JS 编写的网页上的文本字段时遇到问题。

这是有问题的 WebElement:

<input name="CreateUserForename" id="Textc3829619-ad42-4df7-bbe3-5bdbe9fb9bce"
ng-class="{'ng-pristine': controller.$pristine, 'ng-invalid': controller.$invalid,
'ng-invalid-required': controller.$error.required, 'ng-valid': controller.$valid,
'ng-dirty': controller.$dirty}" class="form-input ng-scope ng-valid ng-dirty" type="text"
ng-if="!multiline" ng-hide="disabled" maxlength="">

仅使用 driver.find_element_by_xpath({xpath}).send_keys({keys}) 会出现此错误:

Message: no such element: Unable to locate element: 
{"method":"xpath","selector":"//*[@id="Text9c04f240-66a6-478b-92c2-13bb39379b8e"]"}

使用 css_selector 时相同。

我发现的一种解决方法是使用 ActionChains 和 move_to_element_with_offset,但这并不理想。

有什么想法吗?

(请不要推荐 Protractor )

最佳答案

好吧,看来 driver.find_element_by_name("CreateUserForename") 可以解决问题。

关于python - 无法在Python中使用selenium在Angular JS中定位元素(文本字段),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37791957/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com