Python 如何在selenium webdriver中退出下拉菜单
我将SeleniumWebDriver与Chrome一起使用。我能够从下拉菜单中选择项目,它工作正常 但如果在下拉列表中没有项目,我就不能选择任何其他字段 我把它放在Python 如何在selenium webdriver中退出下拉菜单,python,selenium,selenium-webdriver,webdriver,selenium-chromedriver,Python,Selenium,Selenium Webdriver,Webdriver,Selenium Chromedriver,我将SeleniumWebDriver与Chrome一起使用。我能够从下拉菜单中选择项目,它工作正常 但如果在下拉列表中没有项目,我就不能选择任何其他字段 我把它放在try catch block上,这样它就进入了下一步。如果我尝试选择其他字段并sendKeys,它仍然会将文本添加到下拉搜索栏中 之后,当我尝试点击按钮时,我得到错误: WebDriverException: Message: unknown error: Element is not clickable at point (69
try catch block
上,这样它就进入了下一步。如果我尝试选择其他字段并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中看到光标停留在下拉搜索栏上。我怎样才能退出它?我试图再次点击它以最小化它,但它不会是的,移动焦点有效。以前我试图执行
查找元素…单击()
,但没有成功。但是下面有<代码>ActionChains(self.driver)。将\u移动到\u元素(self.driver。按\u名称('name')查找\u元素)。单击()。执行()您可以共享网页链接吗?您是否尝试将焦点转移到另一个元素?我是否需要导入一些内容以使用ActionChains?是的,您必须从selenium.webdriver.common.action\u chains导入ActionChains之类的内容,而此代码可能会回答问题,如果您解释代码如何以及为什么解决了这个问题,那么对于OP和未来的读者来说,这将非常有用
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