Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Use selenium commands inside an IFRAME

Use selenium commands inside an IFRAME

In a business environment requires a B2B relationship , witch means our project will be integrated with other projects from a different company , for example imagine an id verification form , your company runs a gambling business and they need that functionality , so there are third party on the market that provides it , that means you guys are going to take their form wrap it up in an Iframe and use it , so how to handle iframe in selenium.

page.driver.within_frame('iframe') do
  fill_in 'E-mail', with: '[email protected]'
  fill_in 'Password', with: '***********'
  click_button 'Submit'
end

For more details about within_frame you can check capybara documentation .

#within_frame(element) ⇒ Object
#within_frame(name) ⇒ Object
#within_frame(index) ⇒ Object
How to handle iframe in WebDriver

In Webdriver, you should use driver.switchTo(). to get inside an iframe.

driver.switchTo().frame("iframe");

Keep in mind that webdriver will not know how to switch back to your website from the iframe , you need to tell it :

driver.switchTo().defaultContent();

This was java syntax but is pretty much the same in any other languages.

Happy testing!

How to Scroll Element into View with Selenium

Ruby Capybara select random value from dropdown

How to open a new tab with Selenium

Improve selenium WebDriver tests performance

The post Use selenium commands inside an IFRAME appeared first on TestingRepository.



This post first appeared on Testing Repository - Creating Testing, please read the originial post: here

Share the post

Use selenium commands inside an IFRAME

×

Subscribe to Testing Repository - Creating Testing

Get updates delivered right to your inbox!

Thank you for your subscription

×