我目前正在执行以下自动鳕鱼。它自动工作,但是当它到达关键断言测试时,它不起作用。为什么我的代码失败的任何建议
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");
}
