I want to go inside frame name "body", but it isnt work. I can go to first frame and everything works, but problem is when I try to go inside indeed frameset. Selenium cant see it
This is my code:
frame = driver.find_element(By.XPATH, "/html/frameset/frame[2]")
driver.switch_to.frame(frame)
frame= driver.find_element(By.XPATH, '/html/frameset/frame[1]')
driver.switch_to.frame(frame)
HTML CODE:
<html><head>
<title>
Le Moniteur belge.
</title>
</head>
<frameset rows="14%,*">
<frame src="rech_f1.htm" name="frame1_fr" noresize="">
<frame src="rech_f2.htm" name="frame2_fr" cd_frame_id_="f1e39289d55588245ed84ea909665732">
<html>
<frameset>
<frame src="list_body.pl?language=fr&sql=htit contains 'roche'&fromtab= moftxt UNION montxt UNION modtxt&rech=83&trier=promulgation&tri=dd AS RANK &dt=&ddda=&dddm=&dddj=&ddfa=&ddfm=&ddfj=&pdda=&pddm=&pddj=&pdfa=&pdfm=&pdfj=&numac=&bron=&htit=roche&text1=&choix1=ET&text2=&choix2=ET&text3=&exp=&&fr=f&nl=n&du=d&an=" name="Body" scrolling="auto">
</frameset>
</html>
<noframes>
pas de frames
</noframes>
</frameset>
CodePudding user response:
I guess the second iframe is not inside the first iframe.
If so, after going into the first iframe you need to get back to the default content and only after that to switch to the second iframe, as following:
frame = driver.find_element(By.XPATH, "/html/frameset/frame[2]")
driver.switch_to.frame(frame)
driver.switch_to.default_content()
frame= driver.find_element(By.XPATH, '/html/frameset/frame[1]')
driver.switch_to.frame(frame)
CodePudding user response:
Looks like the frame body
is in the second frameset which is inside the first frameset. So you can find it using full xpath: (By.XPATH, "/html/frameset/frameset/frame")
Or you can try to find it using this realtive XPATH (By.XPATH, "//frame[@name='Body']")]