I have tried to find an element in a page by its id and xpath, but in every case I got the same error message back. I also tried to find the element by the text displayed using the code below, but the problem persisted:
driver.find_elements_by_xpath("//*[contains(text(), 'Uma ou mais sondas DP')]")
I made sure to wait until the page was fully loaded before trying to find the elements.
Any ideas or suggestions on what could be causing this issue?
This is the repository link to access the source code: https://github.com/LucasC97/HTML-Source-Code
Edit: As I mentioned in the comment section, the element is inside an iframe, as shown here. However I got a TimeoutException trying to use the following code before the find_element command, as suggested:
iframe=WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//iframe"))) driver.switch_to.frame(iframe)
I tried to use the find_elements_by_tag_name method to find the iframe elements in the source code, but it returned an empty list.
iframe=WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//iframe"))) driver.switch_to.frame(iframe) driver.find_element_by_id("WFD6") #REMAINING CODE TO INTERACT WITH ELEMENTS INISIDE IFRAME #once done exit from iframe driver.switch_to.default_content()
You have to switch to iframe first to interact with elements inside that ,
Then switch back to interact with elements outside the iframe