2017-05-25 89 views
0

鍵入文本的問題我想輸入文字,並把它想表現在以下鏈接 example of form to be filled out.使用分裂

不過,我無法在字段中鍵入任何內容。我首先認爲它是一個iframe,但分裂無法找到它。如果我通過身體標籤搜索,它會這樣說:

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot focus element 

我該如何解決這個問題?

回答

1

如果你的要素不集中,你必須先移動到使用硒動作該元素如下:

第一招用;

driver.switch_to.frame(driver.find_element_by_css_selector("#inquiry-content_ifr")) 

然後重點元素

yourElement= driver.find_element_by_css_selector(".nav") 

actions = ActionChains(driver) 
actions.move_to_element(menu) 

actions.perform() 

上然後做與該元素的互動後,焦點已被設置爲元素。

+0

我收到以下錯誤:selenium.common.exceptions.NoSuchElementException:消息:沒有這樣的元素:無法找到元素:{「method」:「css selector」,「selector」:「#inquiry-content_ifr」} – sn3jd3r

+0

@ sn3jd3r在哪一行? – kushal