function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Carlos CanedoCarlos Canedo 

Automation with Capybara

Hi,
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.
viruSviruS
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 }
			end
			match || sleep(1)
			retries -= 1
		end

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

within_frame(caseFrame) do
     ...
end