This will be last part of “Handling frames in selenium webdriver”.
We know what is frame and how to handle it in selenium webdriver. But I have seen many queries where people is not able to find whether web element is in frame or not. We will see ways of finding if web element is in frame or not in Firefox and chrome browsers.
Steps to find:
- Right click on web element and click on “Inspect”.
- Go to “Elements” tab and see last row (Node structure) as shown in below pic:
3. The highlighted row displays all ancestor nodes with their ID and class attribute values using CSS selector. If you find any frame/iframe node before your desired web element, you can conclude your web element is inside an frame/iframe.
Steps to find:
- Mouse hover just near to web element and right click.
- If you see context option “View frame source” in context menu, you can conclude desired web element is in frame/iframe.
Firefox browser provides very simple way of identifying if web element in in frame/iframe. Just right click and check context options in context menu. If you are able to find “This Frame” option in context menu, you can conclude web element is in iframe/frame.
I hope, you will be find if web element is in iframe/frame easily in both browsers.
Now we will see sample code with handling frames in selenium webdriver:
- Load MainWindow.htm in browser.
- Type “Top Frame” in TopFrame input box.
- Type “Main Frame” in mainFrame input box.
- Type “Bottom Frame” in bottomFrame input box.
That’s all. I have covered almost all concepts of frame/iframe. If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.