Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
拉诺雷斯。iframe访问问题_Iframe_Webdriver_Ranorex - Fatal编程技术网

拉诺雷斯。iframe访问问题

拉诺雷斯。iframe访问问题,iframe,webdriver,ranorex,Iframe,Webdriver,Ranorex,我尝试在Ranorex中使用WebDriver端点,当Ranorex使用简单路径时,所有这些都可以正常工作,但当它使用iframe时就不行了 如果我提供以下示例,会更好: <div id="layout"> <span id="element1"></span> <iframe id="frame1"> #document <h

我尝试在Ranorex中使用WebDriver端点,当Ranorex使用简单路径时,所有这些都可以正常工作,但当它使用iframe时就不行了

如果我提供以下示例,会更好:

<div id="layout">
    <span id="element1"></span>
    <iframe id="frame1">
        #document
            <html>
                <span id="element2"></span>
            </html>
    </iframe>
</div>
  • WebDriver端点使用:
  • 我可以访问iframe外部包含的元素:(包括iframe本身)

  • 当我尝试使用WebDriver端点访问iframe中包含的任何元素时,出现错误:

    //iframe[#'frame1']//span[#'element2']
    
  • 如何在iframe中使用元素?

    我找到了解决方案

    在Selenium中,我们需要在帧之间切换。 我发现WebDriverDocument具有切换帧的能力:

    WebDriverDocument wd = WebDriverDocument.FromPatch("//*[1]");
    wd.SwitchToFrame("//iframe[@id='frame1']", "xpath");
    // wd.SwitchToFrame("frane1", "id"); - also availabled
    
    之后,我可以管理包含内部iframe的元素:

    WebElement  wl  = "//span[#'element2']";
    
    WebDriverDocument wd = WebDriverDocument.FromPatch("//*[1]");
    wd.SwitchToFrame("//iframe[@id='frame1']", "xpath");
    // wd.SwitchToFrame("frane1", "id"); - also availabled
    
    WebElement  wl  = "//span[#'element2']";