Selenium does not see AngularJS page elements

心已入冬 提交于 2019-12-03 13:24:47

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.

The page source will show the template before it has been compiled by Angular. You should be able to see the compiled template using Chrome's developer console: try right clicking on an element and selecting 'inspect element' to open it up.

driver.getPageSource() will fail for the same reason (it gets the uncompiled template), but driver.findElement() should work just fine.

<input id="username" type="text" ng-model="foo"/>

Should be found using

driver.findElement(By.id("username"));
Jens

I don't think this is angular related but rather Selenium related, Selenium will only have the initial DOM before any JavaScript manipulation of it.

We have seen the same issue with simple jQuery plugins that rendered DOM elements.

See if the advice here helps:

Why can't Selenium find dynamically added DOM elements? Capybara doesn't recognize dynamically added DOM elements?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!