硒不能单击元素

时间:2019-01-20 04:07:52

标签: python selenium selenium-webdriver webdriver

所以最近我遇到了这个错误并解决了这个问题。我设置了硒,以便用户输入文本,并且https://www.dukascopy.com/trading-tools/widgets/quotes/historical_data_feed上的搜索栏显示数据,但是我无法用代码单击结果。the data i am trying to access

1 个答案:

答案 0 :(得分:2)

我们在这里。需要通过单击按钮来切换搜索栏。

... # 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!")