我遇到运行此测试的问题,并希望得到帮助。它打开了firefox并在我在页面上收到此错误后关闭了#34;由于Firefox新功能的兼容性问题,部分禁用了辅助功能支持"。
测试
package com.example.tests;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class QuestionMark {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.gecko.driver", "C:\\SeleniumGecko\\geckodriver.exe");
driver = new FirefoxDriver();
baseUrl = "https://energy.co.uk";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testJava() throws Exception {
driver.get("https://ondemand.questionmark.com/home/403160/");
driver.findElement(By.id("edit-name")).clear();
driver.findElement(By.id("edit-name")).sendKeys("tessy");
driver.findElement(By.id("edit-pass")).clear();
driver.findElement(By.id("edit-pass")).sendKeys("xxxxxx");
driver.findElement(By.id("edit-submit")).click();
assertTrue(driver.findElement(By.xpath("//div[@id='body-container']/div/div/section/div[2]")).getText().matches("^exact:× Error message Sorry, unrecognized username or password\\. Have you forgotten your password[\\s\\S]$"));
assertTrue(driver.findElement(By.linkText("Have you forgotten your password?")).getText().matches("^exact:Have you forgotten your password[\\s\\S]$"));
assertEquals("User", driver.getTitle());
driver.findElement(By.linkText("Request new password")).click();
assertTrue(isElementPresent(By.linkText("Request new password(active tab)")));
assertEquals("User", driver.getTitle());
driver.findElement(By.id("edit-name")).clear();
driver.findElement(By.id("edit-name")).sendKeys("xxxxx@yahoo.com");
driver.findElement(By.id("edit-submit")).click();
assertEquals("User", driver.getTitle());
driver.findElement(By.id("edit-name")).clear();
driver.findElement(By.id("edit-name")).sendKeys("TechTestUser");
driver.findElement(By.id("edit-pass")).clear();
driver.findElement(By.id("edit-pass")).sendKeys("xxxxx");
driver.findElement(By.id("edit-submit")).click();
assertEquals("TechTestUser | 403160", driver.getTitle());
driver.findElement(By.linkText("People")).click();
driver.findElement(By.linkText("Users")).click();
assertEquals("Users", driver.getTitle());
driver.findElement(By.linkText("Import Participants")).click();
assertEquals("Import Participants | 403160", driver.getTitle());
driver.findElement(By.id("edit-feeds-feedsfilefetcher-upload")).clear();
driver.findElement(By.id("edit-feeds-feedsfilefetcher-upload")).sendKeys("C:\\Users\\Tessy\\Downloads\\Participants.csv");
driver.findElement(By.id("edit-submit")).click();
assertEquals("Importing user", driver.getTitle());
assertTrue(isElementPresent(By.xpath("//div[@id='body-container']/div/div/section/div[2]")));
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
以下是日食日志中的错误
2017年6月3日下午1:20:34 org.openqa.selenium.remote.ProtocolHandshake createSession 信息:检测到的方言:W3C JavaScript警告:https://ondemand.questionmark.com/home/403160/sites/all/modules/Community/jquery_update/replace/jquery/1.10/jquery.min.js?v=1.10.2,第1行:不推荐使用// @来表示sourceMappingURL pragma。使用//#代替 JavaScript错误:https://ondemand.questionmark.com/home/403160/sites/all/themes/questionmark/js/main.js?opnqsh,第190行:TypeError:textarea为null 1496492440306 Marionette INFO将不再接受新的连接 [儿童18404] ### !!! ABORT:中止通道错误:文件c:/builds/moz2_slave/m-esr52-w64-000000000000000000/build/src/ipc/glue/MessageChannel.cpp,第2143行 2017年6月3日下午1:20:41 org.openqa.selenium.os.UnixProcess destroy 严重:无法使用PID 636杀死进程