如何退出 selenium webdriver 中的下拉菜单

How to exit dropdown menu in selenium webdriver

我在 Chrome 中使用 selenium webdriver。我可以从下拉菜单中选择 select 项,而且效果很好。

但是如果下拉项中没有项,我就不能 select 任何其他字段。

我说这是 try catch block 所以它进入下一步。如果我尝试 select 其他字段和 sendKeys 它仍然会向下拉搜索栏添加文本。

之后,当我尝试点击按钮时出现错误:

WebDriverException: Message: unknown error: Element is not clickable at point (698, 686). Other element would receive the click: 
  (Session info: chrome=47.0.2526.80)

我可以在 UI 中看到光标停留在下拉搜索栏上。我怎样才能退出它?我试图再次点击它来最小化它,但它不会

是的,移动焦点有效。以前我试图做 find_element...click() 但没有用。但是下面做到了! ActionChains(self.driver).move_to_element(self.driver.find_element_by_name('name')).click().perform()

import org.openqa.selenium.interactions.Actions;

WebDriver driver;

Actions act = new Actions(driver);
act.moveToElement(driver.findElement(By.id("elementID")).click().perform();

//you can use this to move to any other element not intercepted by dropdown list