Protractor testing in iframe in other non-Angular application?

纵然是瞬间 提交于 2019-12-24 03:54:05

问题


My application is integrated with other site. That integration is established by clicking on the button. When I click on the button, pop-up shows with html that comes from another site. I show that content using this by putting URL in iframe. Url is from external site:

<iframe class='' ng-src="{{url}}"></iframe>

Can I execute my protractor test on elements on that pop-up?

When I try to access to element on pop-up by ID, it says No such element found. I got IDs of elements by Firebug tool on Firefox. I hit this, and it returns me false:

expect(element(by.id('**id of element in pop-up**')).isDisplayed()).toBe(true);

Can someone help me with this? Is it possible to run Protractor tests and on this kind of html?


回答1:


You need to switch context to iframe. You can do that by adding these lines of code:

var driver = ptor.driver;
ptor.switchTo().frame(driver.findElement(protractor.By.tagName('iframe')));

Try to access your elements in pop-up now?



来源:https://stackoverflow.com/questions/23805527/protractor-testing-in-iframe-in-other-non-angular-application

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