Using Angular JS(Protractor) with Selenium in Python(在 Python 中使用带有 Selenium 的 Angular JS(量角器))
问题描述
我正在尝试使用 selenium 选择一个包裹在 angular 1 中的文本区域,但在 DOM 中看不到它.有一个名为 Pytractor 的模块.我一直在尝试解决这个问题,但我无法正确使用它.
I'm trying to select a textarea wrapped in angular 1 using selenium, but it can't be seen in DOM. There's a module called Pytractor. I've been trying to solve this but I'm unable to use it correctly.
谁能帮我解决这个问题?
Can anyone help me with this?
推荐答案
您还可以使用常规 selenium 绑定来测试 AngularJS 应用程序.您需要使用 显式等待 来等待元素出现、消失、标题/要更改的 URL 等 - 任何可以让您继续测试页面的操作.
You can also use regular selenium bindings to test AngularJS applications. You would need to use Explicit Waits to wait for elements to appear, disappear, title/url to change etc - for any actions that would let you continue with testing the page.
示例(等待 textarea 元素出现):
Example (waiting for textarea element to appear):
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
wait.until(EC.visibility_of_element_located((By.TAG_NAME, "myaccount")))
<小时>
pytractor(作为 protractor 本身)提供了一件重要的事情 - 它知道 AngularJS 何时完成并准备就绪 - 模型会更新,没有未完成的异步请求等.这并不意味着您必须使用它来测试 AngularJS 应用程序,但它会给您带来优势.
There is one important thing that pytractor (as protractor itself) provides - it knows when AngularJS is settled and ready - models are updated, there are no outstanding async requests etc. It doesn't mean you have to use it to test AngularJS applications, but it gives you an advantage.
此外,pytractor 为您提供了新的定位器,例如您可以通过模型或绑定找到元素.这也不意味着您无法使用 的其他定位技术找到相同的元素常规 selenium python 提供了开箱即用的.
Additionally, pytractor provides you with new locators, e.g. you can find an element by model or binding. It also doesn't mean you cannot find the same element using other location techniques which regular selenium python provides out-of-the-box.
请注意,pytractor 目前并未积极开发和维护.
Note that pytractor is not actively developed and maintained at the moment.
这篇关于在 Python 中使用带有 Selenium 的 Angular JS(量角器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Python 中使用带有 Selenium 的 Angular JS(量角器)
基础教程推荐
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
