代码试用:
chrome[row_index].FindElementByXPath("//*[@id=\"app\"]/div/div[1]/div[2]/div[3]/div[2]/div/button").Submit();
和
chrome[row_index].FindElementByXPath("//*[@id=\"app\"]/div/div[1]/div[2]/div[3]/div[2]/div/button").Click();
这是错误消息:
An exception of type 'OpenQA.Selenium.ElementClickInterceptedException' occurred in WebDriver.dll but was not handled in user code element click intercepted: Element <button data-v-7b27a432="" type="submit" class="btn btn-primary btn-sm form-control mt-3">...</button> is not clickable at point (464, 863). Other element would receive the click: <i data-v-5e808f53="" class="font-20 d-block mb-1 icon-question"></i>
这是按钮的HTML代码:
<button data-v-7b27a432="" type="submit" class="btn btn-primary btn-sm form-control mt-3">Tiếp Tục</button> .
它准备好找到该要素,但无法单击或无法提交该按钮
请尝试以下解决方案:
IWebElement element = driver.FindElement(By.Xpath("//button[contains(text(),'Tiếp Tục')]"));
Actions action = new Actions(Driver);
action.MoveToElement(element).Perform();
action.Click();
单击元素,因此必须为所需的ElementToBeClickable引入WebDriverWait,并且可以使用以下Locator Strategies之一作为解决方案:
使用CssSelector和Submit()
:
new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("button.btn.btn-primary.btn-sm.form-control[type='submit']"))).Submit();
使用XPath和Click()
:
new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[contains(@class, 'form-control') and text()='Tiếp Tục']"))).Click();