Accessing dynamically generated iframe content in Selenium

I want to use XPath (or another Selenium DSL locator) to access a dynamically created iframe . My goal is to make some statements about the contents of this dynamic iframe.

iframe has no identifier and only has the following HTML attributes:

 src="javascript:""" style="position: absolute; left: -2000px;" 

If I can somehow select a Frame, then an iframe , then I can assertText or use XPath to check iframe internal constraints.

However, simple approaches seem to fail. For some reason, selectFrame("index=0") not working. Maybe I need a waitFor way waitFor load the iframe . But I cannot create a locator id for the iframe , so I cannot waitFor .

+6
selenium iframe
source share
1 answer

Have you tried these tips from Selenium docs?

SelectFrame (locator) Selects a frame in the current window. (You can call this command several times to select nested frames.) To select a parent frame, use "relative = parent" as a locator; in select the top frame, use "relative = top". You can also use the DOM expression to determine the desired frame, for example: = ROM frames ["main"]. frames ["stretcher"]

http://release.seleniumhq.org/selenium-core/0.8.0/reference.html

+6
source share

All Articles