Home > Software engineering >  NoSuchElementException: Message: no such element: Unable to locate element: {"method":&quo
NoSuchElementException: Message: no such element: Unable to locate element: {"method":&quo

Time:10-04

Hi yall im having a problem with mi code. I know that i have frames in the web page, but i think that my problem is that i dont know which iframe the "Button" that i want to click is located:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC



s=Service('Webdriver//chromedriver.exe')
driver = webdriver.Chrome(service = s)
driver.maximize_window()

driver.get('http://190.109.11.66:8888/BOE/BI')
iframe = driver.find_element(By.NAME, "servletBridgeIframe") 
driver.switch_to.frame(iframe)
username = driver.find_element(By.XPATH, '//*[@id="_id0:logon:USERNAME"]')
username.send_keys("*****[enter image description here][1]")
password = driver.find_element(By.XPATH, '//*[@id="_id0:logon:PASSWORD"]')
password.send_keys("*****")
login = driver.find_element(By.XPATH, '//*[@id="_id0:logon:logonButton"]')
login.click()
**iframe = driver.find_element(By.XPATH, '//*[@id="iframeHome-122668"]')** 
driver.switch_to.frame(iframe)
wait = WebDriverWait(driver, 10)
**dropdown = driver.find_element(By.XPATH, '//*[@id="header3_5"]')**
dropdown.clcik();
driver.switch_to.default_content()

my guess is that:

dropdown = driver.find_element(By.XPATH, '//*[@id="header3_5"]')

is located in this iframe:

iframe = driver.find_element(By.XPATH, '//*[@id="iframeHome-122668"]')

but im having this error:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="header3_5"]"}

ill attached part of the html and screenshots.

<h3  id="header3_5">Support Manager</h3>
<iframe frameborder="0" id="iframeHome-122668" role="presentation" tabindex="-1" src="http://190.109.11.66:8888/BOE/portal/1906210733/InfoView/listing/home.do?appKind=InfoView&amp;bttoken=MDAwRDc0Om1gVW9TazNCTlkzPEVhaklRb2BnPVViODAEQ" style="width: 300px; height: 540px;"></iframe>

HTML ss

all frames

frame that i think is located

CodePudding user response:

Try to switch to iframe and I use css selectors:

iframe =WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe#iframeHome-122668")))
  • Related