采用了棱角分明JS(量角器)与Python中硒 [英] Using Angular JS(Protractor) with Selenium in Python

查看:298
本文介绍了采用了棱角分明JS(量角器)与Python中硒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想选择包裹在使用硒角JS一个textarea,但它不能在DOM中可以看出。有一个叫Pytractor模块( https://pypi.python.org/pypi/pytractor/0.0 .1 )我一直在试图用它来解决这个问题,但我无法正确地使用它。

I'm trying to select a textarea wrapped in angular js using selenium, but it can't be seen in DOM. There's a module called Pytractor (https://pypi.python.org/pypi/pytractor/0.0.1) I've been trying to use to solve this but I'm unable to use it correctly.

谁能帮我?

推荐答案

您也可以使用常规的硒绑定测试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 (如量角器本身)提供 - 它知道何时 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 为您提供了新的定位器,例如你可以找到通过模型或绑定的元素。这也并不意味着使用其他定位技术无法找到相同的元素,它定期硒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.

这篇关于采用了棱角分明JS(量角器)与Python中硒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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