Need Help in getting XPath expression for span inside an Iframe popup

前端 未结 5 570
清歌不尽
清歌不尽 2021-01-02 23:30

Need to get an xpath expression for the span inside the iframe. Need Help in getting XPath expression for span inside an Iframe popup.

i can get the iframe but getti

5条回答
  •  渐次进展
    2021-01-03 00:10

    We can't access elements within an iframe directly. We need to switch to iframe first.

    I am using PHP Facebook webdriver and this is perfectly working for me:

    $driver->get("http://www.example.com"); // containing an iframe
    $iFrame = $driver->findElement(
                WebDriverBy::xpath('//iframe[@name="iFrameName"]') //name or id or whatever by which we can access.
            );
    $driver->switchTo()->frame($iFrame);
    

    Now, we can access that span as:

    $spanButton = $driver->findElement(
                WebDriverBy::xpath('//span') 
            );
    

提交回复
热议问题