I need to get the result from the table \"td\". But before I can do that I need to navigate a frame that contains it. The frame is one of the frameset elements that belongs
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));
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.
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.
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]'))