driver.findElement(By.xpath("//*[@id='submitButton']")).click();
Alert alert = driver.switchTo().alert();// error message on eclipse *Type mismatch: cannot convert from org.openqa.selenium.Alert to Alert*
String alertText = alert.getText();// The method getText() is undefined for the type Alert
alert.accept();// The method accept() is undefined for the type Alert
return alertText;
类型提醒未定义driver.switchTo().alert();
和getText();
accept();
方法的错误。
答案 0 :(得分:0)
您应该导入以下内容:
import org.openqa.selenium.Alert;
上面提到的import语句可以解决问题。