Hi,
If I have found an iFrame and stored it in a Ranorex iFrameTag object, and now I want to use Selenium code to switch to the frame, I know I can do this via 4 different ways; By ID, By Name, By Index, and By Selenium WebDriver WebElement.
For the sake of argument, lets suppose the iFrame I have found has no ID or Name.
1) How can I get the index of this frame relative to other frames at the same level in the Dom structure ?
2) Is it possible to convert a Ranorex iFrameTag to a Selenium WebDriver WebElement?
Thanks,
Aracknid
How to switch to iFrame using WebDriver code
Re: How to switch to iFrame using WebDriver code
If there is no name or or ID, I have seen Ranorex use the Src attribute for the path:
However if none of that is available, it should default to index:
If you want, you can even force Ranorex to use an index for this item. When you track it, open the path editor in Spy and check the index box under general:
Now that your Ranorex paths are using index, you know ahead of time what the index will be. As far as converting a Selenium type to a Ranorex type, I don't think this is possible as far as I know unless you convert it property by property yourself. I do know that there is a good amount of overlap between RxPath and XPath so maybe I would start there.
Code: Select all
/dom[@caption='Tryit Editor v3.5']//iframe[#'iframeResult']/?/?/iframe[@src='https://www.w3schools.com/']
Code: Select all
/dom[@caption='Tryit Editor v3.5']//iframe[#'iframeResult']/?/?/iframe[1]
Re: How to switch to iFrame using WebDriver code
Sorry, I should have been more clear.
My script is based on code using the Ranorex API in Visual Studio. I'm not using Ranorex Studio.
In my code, I already have the iFrame object stored in a variable (I found it using Ranorex code). I'm checking the ID and Name field in code to see if they are blank or not. If they are not blank, I will switch to the frame using the ID or Name. BUT if they are blank, I need to use index or Selenium WebElement. In code (programmatically), can I find out the index of the iFrame relative to other iFrames? IF not, can I convert the iFrame to a Selenium WebElement?
Why am I asking this...? Because (for example) say I have an xPath like this: .//div[#'someID']//iframe//input[#'someotherID']
If I'm looking off the DOM using Ranorex, I can easily find the input. But If I'm running through WebDriver to test against Edge, it will not work since it's within an iFrame and Selenium WebDriver doesn't support work the way Ranorex does. With Selenium, First you need to find the iFrame, then switch to it, and then find the input.
In this simple example, I can find the I frame using Ranorex. But to switch to it, I need to know it's index since it has no ID or Name. Or I need to convert the Ranorex iFrame to a Selenium WebElement if that is possible.
Thanks,
Aracknid
Thanks,
Matt.
My script is based on code using the Ranorex API in Visual Studio. I'm not using Ranorex Studio.
In my code, I already have the iFrame object stored in a variable (I found it using Ranorex code). I'm checking the ID and Name field in code to see if they are blank or not. If they are not blank, I will switch to the frame using the ID or Name. BUT if they are blank, I need to use index or Selenium WebElement. In code (programmatically), can I find out the index of the iFrame relative to other iFrames? IF not, can I convert the iFrame to a Selenium WebElement?
Why am I asking this...? Because (for example) say I have an xPath like this: .//div[#'someID']//iframe//input[#'someotherID']
If I'm looking off the DOM using Ranorex, I can easily find the input. But If I'm running through WebDriver to test against Edge, it will not work since it's within an iFrame and Selenium WebDriver doesn't support work the way Ranorex does. With Selenium, First you need to find the iFrame, then switch to it, and then find the input.
In this simple example, I can find the I frame using Ranorex. But to switch to it, I need to know it's index since it has no ID or Name. Or I need to convert the Ranorex iFrame to a Selenium WebElement if that is possible.
Thanks,
Aracknid
Thanks,
Matt.
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to switch to iFrame using WebDriver code
Hi All,
We are currently working on this issue with the customer via a support ticket and will update this post with new information as it becomes available.
*Update*: This issue was caused by a bug and has been resolved in Ranorex 8.1.0:
Ranorex Release Notes
Thank you for your patience!
-Jon
We are currently working on this issue with the customer via a support ticket and will update this post with new information as it becomes available.
*Update*: This issue was caused by a bug and has been resolved in Ranorex 8.1.0:
Ranorex Release Notes
Thank you for your patience!
-Jon