嘗試用ID,但如果它不是你可以與其他定位器試試,我建議你使用的XPath:
driver.findElement(By.xpath("//input[contains(@id,'confirmButtonTop')]")).click();
或
driver.findElement(By.xpath("//*[contains(@id,'confirmButtonTop')]")).click();
還我會建議你可以使用等到元素可以點擊,或可見
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[contains(@id,'confirmButtonTop')]")));
driver.findElement(By.xpath("//input[contains(@id,'confirmButtonTop')]")).click();
或
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[contains(@id,'confirmButtonTop')]")));
driver.findElement(By.xpath("//*[contains(@id,'confirmButtonTop')]")).click();