How to navigate a subframe inside a frameset using Selenium WebDriver?

自作多情 提交于 2019-11-26 23:03:48
CHEBURASHKA

I agree, you cannot directly switch to a child frame. Also, make sure to switch to the defaultContent (driver.switchTo.defaultContent) every time you want to switch frame. With regard to your example, driver.switchTo().frame("mainFrame.0.child") --- this could also work, but you need to get rid of unnecessary quotation marks.

Find the index of main frame starting from zero then use

driver.switchTo.frame(mainFrameindex);

Then find the index of sub frame in the main frame

driver.switchTo.frame(subFrameIndex);

You cannot directly switch to a child frame without first switching to the parent frame. This is how it works.

You can switch directly to the frame you want with the xPath. Get the Xpath through the Developer console, then:

driver.switch_to.frame(driver.find_element_by_xpath('html / frameset / frameset / frame[1]'))

Ryan

Through chaining methods together, once you switchTo().defaultContent, you can create temporary lists of available frames through findElements() by tagName and go to that specific frames' index...

For example

driver.switchTo()defaultContent();
driver.switchTo().frame(driver.findElement(By.tagName("frameset")).findElements(By.tagName("frame")).get(2));
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!