2017-05-25 90 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