2

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?

Dejan Jankovic
  • 173
  • 4
  • 11
  • Have you seen [this question](http://stackoverflow.com/questions/20425909/protractor-testing-angular-app-in-an-iframe) ? – glepretre May 22 '14 at 13:50
  • Yea, but I can not switch to my iframe. When i hit: ptor.switchTo().frame(driver.findElement(protractor.By.xpath('//iframe'))); it says me that is not iframe on page. – Dejan Jankovic May 22 '14 at 13:54
  • I set ID to iframe and try to access by id, but it says: "No such element." – Dejan Jankovic May 22 '14 at 14:00
  • I can switch to iframe by using tagName, but I still can not access to button on that pop-up – Dejan Jankovic May 22 '14 at 14:11
  • When you say pop-up, what do you mean? Is it a new window? A simple div which is designed as a pop-up? Can you provide an example in JS-bin or the link itself? – dcoder Aug 18 '14 at 12:40

1 Answers1

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?

Django
  • 43
  • 2
  • 10