在移动仿真模式下,Selenium C# 无法单击 cookie 策略关闭图标的问题可能是由于多种原因导致的。以下是一些建议来解决这个问题:
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement closeButton = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id("cookiePolicyCloseIcon")));
closeButton.Click();
IWebElement closeButton = driver.FindElement(By.XPath("//div[@class='cookie-policy']//button[@id='cookiePolicyCloseIcon']"));
closeButton.Click();
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("arguments[0].scrollIntoView();", closeButton);
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("arguments[0].click();", closeButton);
领取专属 10元无门槛券
手把手带您无忧上云