+ Start a Discussion
Carlos CanedoCarlos Canedo 

Automation with Capybara

I am automating some test cases using  Capybara with a custom tab, which content is embedded in a iframe. The issue is that UI elements contained in the iframe are not recognized properly by Capibara. In the other hand, UI outside the iframe (i.e. menus, login) are recognized properly
Any ideas on this?
Thanks for your kind cooperation.
Did you tried using Jquery ..
Ed GroenendaalEd Groenendaal
What I have done here (Lightning) is write a function that finds the correct iframe and returns it. I use the CSS pageType to identify the tab that I want. The iframe is then returned so that the Capybara can use within_frame() on that.

For example:
def find_frame_with_page_type(page_type)
		retries = 4
		match = false

		while retries > 0 do
			match = all('iframe').find do |frame|
				within_frame(frame) { all('.pageType', text: page_type).first }
			match || sleep(1)
			retries -= 1

		match || fail("Could not find iframe with page type #{page_type}")
caseFrame = find_frame_with_page_type("Case Edit")

within_frame(caseFrame) do