我遇到了隐藏元素的问题。该站点已完全加载,因此所有可用的项目,无需加载,切换页面。我尝试了使用 ExpectedConditions 的所有选项,但仍然没有等待元素。使用 Find 功能,我得到了位置,但是 x,y 坐标是:(-125, 156),因此无法单击它(在屏幕上也不可见)非常糟糕的解决方法是 while + Thread.Sleep( 1000); 和一个计数器..while x>0 and >0 我想避免..有什么想法吗? 代码示例:
ChromeOptions chromeCapabilities = new ChromeOptions();
chromeCapabilities.EnableMobileEmulation("iPhone 7");
IWebDriver webDriver = new ChromeDriver(chromeCapabilities);
webDriver.Manage().Window.Maximize();
webDriver.Navigate().GoToUrl("https://m.exmaple.org");
WebDriverWait driverWait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(30.0));
IWebElement menu_1;
IWebElement switch_left;
switch_left = webDriver.FindElement(By.Id("item_1"));
switch_left.Click(); // ~3-5 sec while switched left because of animations
driverWait.Until(ExpectedConditions.ElementToBeClickable(By.Id("item_1"))));
menu_1 = webDriver.FindElement(By.Id("item_1"));
menu_1.Click(); System.InvalidOperationException: 'unknown error: Element is not clickable at point (-125, 156)