How to select a frame using selenium?

前端 未结 5 568
清酒与你
清酒与你 2020-12-19 16:40

I\'m using Java to create selenium test cases. My system is based on portlets connected to each other. I\'m using \"selectFrame\" command to select the portlet.

I tr

5条回答
  •  一整个雨季
    2020-12-19 17:07

    You have an XPath expression that is supposed to get you the IFrame element you need. However you are not telling Selenium it's an XPath expression. The below is what you need:

    driver.switchTo().frame(driver.findElement(By.xpath("//iframe[contains(@src,'FUN_UnitList_FilterByLevelIndexOne')]"));
    

    Note, my Java is not it's best, so this may cause compilation issues but you should see the idea.

    Find the element first, by telling Selenium it's an XPath expression you are giving it, then use that element and stick it right in the 'switch to frame' expression.

提交回复
热议问题