How to know in which iframe we are or whether the element is present in the source code or not?

Its very hard specially when we have nested iframes to know in which iframe we are currently working.
also the situation comes when we want to know whether the element is present in the source code we are currently pointing to.

By using Assertion we can easily know it.

Also remember if the Assertions fails the script will Stop and will not execute the steps after assertions.

  assertTrue(driver.getPageSource().contains("Text-you-are-Looking-for"));  

Advertisements

2 thoughts on “How to know in which iframe we are or whether the element is present in the source code or not?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s