protractor icon indicating copy to clipboard operation
protractor copied to clipboard

unable to select iframe element using locators

Open Hardcode37 opened this issue 13 years ago • 6 comments

I have been trying to click an anchor element from inside an iframe on one of my views and so far I have been unable to achieve this.

I have so far tried the locators below ptor.findElement(protractor.By.css()).click(), ptor.findElement(protractor.By.xpath()).click(), ptor.findElement(protractor.By.id()).click() and ptor.findElement(protractor.By.name()).click()

along with all of the above locators I have tried the same using webdriver and as yet am still unable to grab the element.

Is there a way of achieving this is it a limitation?

Hardcode37 avatar Sep 10 '13 13:09 Hardcode37

Hi! To do something in another frame or window, you're going to have to tell Webdriver to switch contexts. You can do this with

ptor.switchTo().frame('<framename>')

See this for more documentation: https://code.google.com/p/selenium/source/browse/javascript/webdriver/webdriver.js#1375

juliemr avatar Sep 10 '13 17:09 juliemr

Works like a charm. Thank you

Keep up the great work.

Hardcode37 avatar Sep 11 '13 08:09 Hardcode37

Hy, I have problem with accessing elements in iframe, although i switched successfully to iframe by this lines:

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

But those elements are still invisible when i try to access them by Id, tagName, xpath.

Do you know maybe some solution?

Regards

lovacuzitu avatar May 22 '14 14:05 lovacuzitu

@juliemr thanks! this one helped a lot

vsergi23 avatar Nov 13 '14 14:11 vsergi23

Encountering the same problem with @lovacuzitu. Any update?

quiz1991 avatar Apr 03 '15 19:04 quiz1991

Got same issue, unable to find iframe to check its size with getSize()

tot-ra avatar Feb 04 '16 14:02 tot-ra