0
我想捕获gmail登录时的错误消息如果我不填充用户名并单击下一步按钮,则会出现“请输入您的电子邮件”消息,但是Selenium给出错误消息 - 参数未找到。 我的代码是:Selenium WebDriver无法捕获gmail登录的错误消息
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
public class Msg
{
public static void main(String[] args) throws InterruptedException
{
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("http://www.gmail.com/");
driver.findElement(By.xpath(".//*[@id='next']")).click();
Thread.sleep(2000);
WebElement ele=driver.findElement(By.xpath(".//*[@id='next']"));
String js="argument[0].style.height='auto'; argument[0].style.visibility='visible';";
((JavascriptExecutor)driver).executeScript(js,ele);
String actual=ele.getText();
System.out.println(actual);
//String expected= "Please enter your email";
Assert.assertEquals(actual, "Please enter your email");
System.out.println("Pass");
}
}
能否请你分享你所得到的错误讯息? – Harish