Java 断言测试无法通过,只是-Selenium问题
我目前正在进行下面的自动cod测试。它会自动工作,但是当它到达密钥断言测试时,它就不工作了。我的代码失败的原因有什么建议吗Java 断言测试无法通过,只是-Selenium问题,java,selenium,assert,Java,Selenium,Assert,我目前正在进行下面的自动cod测试。它会自动工作,但是当它到达密钥断言测试时,它就不工作了。我的代码失败的原因有什么建议吗 package Key; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.seleni
package Key;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.junit.Test;
import org.junit.Assert;
public class KeyEvent {
@Test
public void keyEventTest() throws Exception {
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://the-internet.herokuapp.com/key_presses");
driver.manage().window().maximize();
Actions action= new Actions (driver);
action.sendKeys(Keys.SPACE).build().perform();
String text = driver.findElement(By.id("result")).getText();
System.out.println(text);
Assert.assertEquals (text,"You entered : Space");
}它像打字一样简单吗 断言区分大小写,区分空白 将应用程序手动生成的内容与您期望的内容进行比较:
- 您有:
您输入了:空格
- My Chrome已
您输入了:空格
我还没有试过。但这可能就是为什么我的测试没有产生奇妙的绿色阴影来分类它。谢谢