3 回答

TA貢獻1810條經驗 獲得超4個贊
driver.FindElement(By.XPath("//*[@id='commentSFHD-12']")).SendKeys("TEST Function");
System.Threading.Thread.Sleep(5000);
IWebElement ibtn3 = driver.FindElement(By.Id("public"));
IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;
executor.ExecuteScript("arguments[0].click();", ibtn3);
通過使用上面的代碼,它現在可以正常工作

TA貢獻1811條經驗 獲得超4個贊
您可以這樣使用,因為您沒有共享 URL,因此很難找到結論。但是試試這個:
WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.ElementToBeClickable(element));
或者
WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.visibilityOfElementLocated(element));

TA貢獻1856條經驗 獲得超17個贊
根據您共享的HTML,單擊帶有公共文本的按鈕,您需要引入WebDriverWait以使所需元素可點擊,您可以使用以下解決方案:
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@class='actionButton-container row']//button[@class='btn blue changeBtn' and @id='public']"))).Click();
- 3 回答
- 0 關注
- 241 瀏覽
添加回答
舉報