Selenium 看不到 AngularJS 页面元素 [英] Selenium does not see AngularJS page elements

查看:37
本文介绍了Selenium 看不到 AngularJS 页面元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编写 Selenium 测试来检查我的应用程序时遇到问题.我要测试的是当用户输入正确的登录名/密码时,显示正确的页面并且用户已登录.

I have problem with writing Selenium test to check my application. What I want to test is when user types correct login/password, correct page is shown and user is logged in.

主要问题是我的登录表单是作为 AngularJS 指令生成的(我有两个不同的登录页面,并且该指令在两个地方都重复使用),而 Selenium 似乎无法从该指令生成的标记中看到元素.最重要的是,在我用生成的指令替换常规标记之前,测试在此页面上通过.

The main issue is that my login form is generated as a AngularJS directive (I have two different login pages and this directive is reused in both places) and Selenium seems to be unable to see elements from this directive-generated markup. What is most important, tests were passing on this page before I've replaced regular markup with generated by directive.

所以看起来 Selenium 无法看到指令生成的 html 元素.

So it looks like somehow Selenium is not able to see html elements that are generated by directive.

有什么建议可以解决这个问题吗?当然,除了恢复此更改引入指令:)

Any suggestion how I could overcome this issue? Except of course reverting this change introducing directive :)

推荐答案

好吧,看来是我误用了 Geb 和 Selenium.我没有指定默认驱动程序,Geb 选择了一个不适用于 AngularJS 的驱动程序.在我手动将驱动程序更改为 Chrome 后,一切都开始工作了.

Ok, it looks like it was me misusing Geb with Selenium. I didn't specify default driver and Geb picked one not working with AngularJS. After I manually changed driver to Chrome, everything started to work.

这篇关于Selenium 看不到 AngularJS 页面元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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