Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 断言测试无法通过,只是-Selenium问题_Java_Selenium_Assert - Fatal编程技术网

Java 断言测试无法通过,只是-Selenium问题

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

我目前正在进行下面的自动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.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已
    您输入了:空格

这就是我的样子:


我还没有试过。但这可能就是为什么我的测试没有产生奇妙的绿色阴影来分类它。谢谢