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(量角器)
基础教程推荐
- 修改列表中的数据帧不起作用 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 包装空间模型 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 求两个直方图的卷积 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
