I am having an issue with Selenium and not being able to switch to a frame. I have tried using the xpath of iframe but it replies that the element was not found. This was the code I was using:
driver.switch_to_frame(driver.find_element_by_xpath('//[@id="VF"]'))
I have also tried using a css-selector but it gives me the same result. I suspect that the div element that holds the iframe that I want to select is causing this issue but I'm not sure. Here's what that div element looks like:
<div id="dee_0" class="ar BAResults" fframe='<iframe title="SRC" src="javascript:"<HTML></HTML>"" onload="DVFol()"></iframe>
Any help would be greatly appreciated.
edit this is the iframe I'm trying to target
<iframe name="VF" title="SRC" id="VF" src='javascript:"<HTML></HTML>"' frameborder="0" scrolling="auto" style="left: 0px; top: 0px; width: 830px; height: 490px; background-color: transparent;" allowtransparency="true" onload="F(0,302899400).ol()">
stack trace
Traceback (most recent call last):
File "C:/Users/kthao.ISC/PycharmProjects/AutoComplete/test2.py", line 32, in
<module>
chrome.switch_to_frame(chrome.find_element_by_xpath('//*
[@id="VF"]'))
File "C:\Users\kthao.ISC\Desktop\AutoComplete\lib\site-
packages\selenium\webdriver\remote\webdriver.py", line 368, in
find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\kthao.ISC\Desktop\AutoComplete\lib\site-
packages\selenium\webdriver\remote\webdriver.py", line 858, in find_element
'value': value})['value']
File "C:\Users\kthao.ISC\Desktop\AutoComplete\lib\site-
packages\selenium\webdriver\remote\webdriver.py", line 311, in execute
self.error_handler.check_response(response)
File "C:\Users\kthao.ISC\Desktop\AutoComplete\lib\site-
packages\selenium\webdriver\remote\errorhandler.py", line 237, in
check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element:
Unable to locate element: {"method":"xpath","selector":"//*
[@id="VF"]"}