So recently I came across this error and get around it. I have selenium set up in a way that a user enters text and the search bar on https://www.dukascopy.com/trading-tools/widgets/quotes/historical_data_feed displays the data however I can't click the result with my code.
Asked
Active
Viewed 103 times
0

Robex
- 47
- 3
- 9
-
That search bar is inside an `iframe` tag. You'll need to switch to that `iframe` to interact with the element -> https://stackoverflow.com/questions/44834358/switch-to-an-iframe-through-selenium-and-python?rq=1 – Wiggy A. Jan 20 '19 at 04:19
-
there were two nested iframes and i tries switching them in every possible way but i couldnt select the option – Robex Jan 20 '19 at 04:32
1 Answers
2
Here we go. The search bar needed to be toggled through a button click.
... # Driver initialization, navigating to the page etc.
# The first nested frame
frame_1 = driver.find_element_by_id("widget-container")
driver.switch_to.frame(frame_1)
# The second nested frame
frame_2 = driver.find_element_by_tag_name("iframe")
driver.switch_to.frame(frame_2)
# Toggling the search bar
driver.find_element_by_xpath("//div[contains(text(), 'Instrument')]").click()
# Actually sending in the query
search = driver.find_element_by_xpath("//input[@placeholder='Instrument']")
search.send_keys("Hey there!")

Wiggy A.
- 496
- 3
- 16