Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fix path for test file resources
Browse files Browse the repository at this point in the history
Tests were using a relative path rather than a process resource path
which had unintended results.
In attempting to fix this, a problem presented with clicks to cke
editors, which this also fixes.
  • Loading branch information
djansen-redhat committed Mar 10, 2014
1 parent 86bf324 commit ae251e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 7 additions & 1 deletion functional-test/src/main/java/org/zanata/page/CorePage.java
Expand Up @@ -24,6 +24,7 @@
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Predicate;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Expand All @@ -40,6 +41,7 @@
* @author Damian Jansen <a
* href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@Slf4j
public class CorePage extends AbstractPage {

@FindBy(id = "home")
Expand Down Expand Up @@ -131,7 +133,11 @@ public boolean hasNoCriticalErrors() {
* only exhibit behaviour on losing focus.
*/
public void defocus() {
getDriver().findElement(By.tagName("body")).click();
if (getDriver().findElements(By.id("container")).size() > 0) {
getDriver().findElement(By.id("container")).click();
} else {
log.warn("Unable to focus page container");
}
}

public List<String> waitForFieldErrors() {
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.openqa.selenium.support.ui.Select;
import org.zanata.page.BasePage;
import org.zanata.util.Constants;
import org.zanata.util.WebElementUtil;

import java.util.Map;

Expand All @@ -51,7 +52,7 @@ public class CreateProjectPage extends BasePage {
"machineReadableSourceUrlField:machineReadableSourceUrl")
private WebElement downloadSourceURLField;

@FindBy(id = "cke_projectForm:homeContentField:homeContent:inp")
@FindBy(id = "projectForm:homeContentField:homeContent")
private WebElement homeContentTextArea;

@FindBy(id = "projectForm:statusField:selectField")
Expand Down Expand Up @@ -111,7 +112,9 @@ public CreateProjectPage enterDownloadSourceURL(String url) {
}

public CreateProjectPage enterHomepageContent(String content) {
homeContentTextArea.sendKeys(content);
//homeContentTextArea.sendKeys(content);
WebElementUtil.setRichTextEditorContent(getDriver(),
homeContentTextArea, content);
return this;
}

Expand Down
Expand Up @@ -26,6 +26,7 @@
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -234,9 +235,9 @@ private static class ZanataXml {
}

public File openTestFile(String filename) {
String relativePath = "functional-test/target/test-classes/"
.concat(filename);
File testFile = new File(relativePath);
URL url = Thread.currentThread().getContextClassLoader()
.getResource(filename);
File testFile = new File(url.getPath());
assert testFile.exists();
return testFile;
}
Expand Down

0 comments on commit ae251e0

Please sign in to comment.