So I'm trying to select a frame using selenium. I found many examples and similar questions on stackoverflow regarding this.
All of them pointed out that to select elements that are in a frame you first have to "move" to that frame and then get the element you want. But I can't seem to get the frame that I want.
All the post I read said use:
driver.switch_to.frame("contentfrm") # Fetch by name, or
driver.switch_to.frame(1) # Fetch by index
So I tries all of them and no matter what I use I always get an error that says it cannot find the frame, selenium.common.exceptions.NoSuchFrameException: Message: Unable to locate frame: contentfrm
The python code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://10.0.0.2/html/content1.asp")
driver.get("10.0.0.2")
elem = driver.find_element_by_name("Username")
elem.send_keys("admin")
elem = driver.find_element_by_name("Password")
elem.send_keys("admin2")
elem.send_keys(Keys.ENTER)
# ----
driver.switch_to.default_content()
driver.switch_to.frame("contentfrm")
# elem = driver.find_element_by_id("m8")
# driver.quit()
The HTML code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Quick Start</title>
</head>
<frameset onload="load()" rows="0,*" frameborder="0" border="0" framespacing="0">
<frame name="topFrame" scrolling="no" src="../main/refresh.asp" __idm_frm__="200"></frame>
<frame name="contentfrm" id="contentfrm" __idm_frm__="201"></frame>
</frameset>
</html>
Note: The code works correctly up to where I have to select the frame.
Any idea why this is happening
topFrame?switchstatement and also give some wait time before finding the element ``` driver.switch_to.frame("contentfrm"); WebDriverWait wait = new WebDriverWait(driver, 15); wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(" "))); ```