I try to use WebDriver endpoint with Ranorex and all works well when Ranorex works with a simple path, but not when it works with iframe.
It will be better if I provide the example:
<div id="layout">
<span id="element1"></span>
<iframe id="frame1">
#document
<html>
<span id="element2"></span>
</html>
</iframe>
</div>
I can access to any element Ranorex endpoint using:
//span[#'element1']
//iframe[#'frame1']//span[#'element2']
I can access the elements that contained outside the iframe: (including the iframe itself)
//span[#'element1']
//iframe[#'frame1']
I have the error when I try to get access with WebDriver endpoint to any element that contains inside iframe :
//iframe[#'frame1']//span[#'element2']
How I can use elements in iframe?
I found solution.
As in the Selenium we need to switch between frames. I found that WebDriverDocument has the ability to switch frames:
WebDriverDocument wd = WebDriverDocument.FromPatch("//*[1]");
wd.SwitchToFrame("//iframe[@id='frame1']", "xpath");
// wd.SwitchToFrame("frane1", "id"); - also availabled
After that I can manage elements that contained inner iframe:
WebElement wl = "//span[#'element2']";