Skip to content

Commit

Permalink
Add new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey.pensov authored and sergey.pensov committed Nov 27, 2014
1 parent c55bce8 commit e4015a7
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 2 deletions.
7 changes: 7 additions & 0 deletions OpenFaces.ipr
Expand Up @@ -1390,6 +1390,13 @@
<root url="jar://$PROJECT_DIR$/libsrc/richfaces-core-api-4.0.0.Final-sources.jar!/" />
</SOURCES>
</library>
<library name="selenide">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/selenium/selenide-2.14.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
<library name="selenium-java-client-driver">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/seleniuminspector/selenium-java-2.14.0.jar!/" />
Expand Down
14 changes: 14 additions & 0 deletions OpenFacesWebDriverInspector/OpenFacesWebDriverInspector.iml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="selenide" level="project" />
<orderEntry type="library" name="selenium-webDriver" level="project" />
</component>
</module>

1 change: 1 addition & 0 deletions build.xml
Expand Up @@ -222,6 +222,7 @@
<pathelement path="testLib/junit.jar"/>
<pathelement path="lib/selenium/selenium-java-2.44.0.jar"/>
<pathelement path="lib/selenium/selenium-server-standalone-2.44.0.jar"/>
<pathelement path="lib/selenium/selenide-2.14.jar"/>
</classpath>
</javac>
</target>
Expand Down
Binary file added lib/selenium/selenide-2.14.jar
Binary file not shown.
89 changes: 89 additions & 0 deletions webDriverFuncTests/source/org/openfaces/test/AjaxTest.java
@@ -0,0 +1,89 @@
/*
* OpenFaces - JSF Component Library 3.0
* Copyright (C) 2007-2014, TeamDev Ltd.
* licensing@openfaces.org
* Unless agreed in writing the contents of this file are subject to
* the GNU Lesser General Public License Version 2.1 (the "LGPL" License).
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Please visit http://openfaces.org/licensing/ for more details.
*/
package org.openfaces.test;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openfaces.test.componentInspector.Element;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.server.SeleniumServer;

import static com.codeborne.selenide.Selenide.*;
import static com.codeborne.selenide.Condition.*;
import static com.codeborne.selenide.Selenide.open;
import static com.thoughtworks.selenium.SeleneseTestBase.*;

import java.util.List;

/**
* @author Tatyana Matveyeva
*/
public class AjaxTest extends WebDriverSeleniumTestCase {
private DefaultSelenium localhost;
private SeleniumServer seleniumServer;
private WebDriver driver;

@Before
public void setUp() throws Exception {
// localhost = new DefaultSelenium("localhost", 4444, "*chrome", "http://openfaces.org.test");
seleniumServer = new SeleniumServer();
seleniumServer.start();
driver = new FirefoxDriver();
// localhost.start();
}

@After
public void tearDown() throws Exception {
seleniumServer.stop();
}


//All DataTable features, that use Ajax is Tested on the demo (DataTable_general.jsf)
@Test
public void testFoldingPanelAjax() throws Exception {
open("/components/foldingpanel/foldingPanelAjax.jsf");
assertFalse(element("form1:Output").isElementInPage());
foldingPanel("form1:fp1").toggle();
assertTrue(element("form1:output1").isElementInPage());
assertTrue(element("form1:input1").isElementInPage());

}

@Test
public void testTabbedPaneAjax() throws Exception {
open("/components/tabbedpane/tabbedPaneAjax.jsf");
Element tab1Output = element("form1:tab1Output");
assertTrue(tab1Output.isElementInPage());
Element tab2Output = element("form1:tab2Output");
assertFalse(tab2Output.isElementInPage());
Element tab3Output = element("form1:tab3Output");
assertFalse(tab3Output.isElementInPage());
Element tab4Output = element("form1:tab4Output");
assertFalse(tab4Output.isElementInPage());
List<Element> tabs = tabbedPane("form1:tp1").tabSet().getTabs();
/* tabs.get(1).clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
tab2Output.assertElementExists(true);
tabs.get(2).clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
tab3Output.assertElementExists(true);
tabs.get(3).clickAndWait(OpenFacesAjaxLoadingMode.getInstance());
tab4Output.assertElementExists(true);
tabs.get(0).click();
tab1Output.assertElementExists(true);*/
}


}
Expand Up @@ -43,7 +43,7 @@ public void tearDown() throws Exception {

@Test
public void testAvailability() {
WebDriver driver = new FirefoxDriver();
driver = new FirefoxDriver();
driver.get("http://localhost:8080/overview/homepage.jsf");
}
}
Expand Up @@ -13,6 +13,10 @@
package org.openfaces.test;

import com.thoughtworks.selenium.SeleneseTestCase;
import org.openfaces.test.componentInspector.Element;
import org.openfaces.test.componentInspector.FoldingPanelInspector;
import org.openfaces.test.componentInspector.TabbedPaneInspector;
import org.openqa.selenium.WebDriver;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -21,7 +25,7 @@
/**
* Author: Andrew.Palval@teamdev.com
*/
public abstract class WebDriverSeleniumTestCase extends SeleneseTestCase {
public abstract class WebDriverSeleniumTestCase {

static {
// Properties properties = new Properties();
Expand All @@ -34,4 +38,17 @@ public abstract class WebDriverSeleniumTestCase extends SeleneseTestCase {
// String startUrl = properties.getProperty("org.openfaces.funcTests.startUrl");

}
protected static WebDriver driver;

protected FoldingPanelInspector foldingPanel(String id) {
return new FoldingPanelInspector(id);
}

protected Element element(String id) {
return new Element(id);
}

protected TabbedPaneInspector tabbedPane(String id) {
return new TabbedPaneInspector(id);
}
}
@@ -0,0 +1,49 @@
package org.openfaces.test.componentInspector;/*
* OpenFaces - JSF Component Library 3.0
* Copyright (C) 2007-2014, TeamDev Ltd.
* licensing@openfaces.org
* Unless agreed in writing the contents of this file are subject to
* the GNU Lesser General Public License Version 2.1 (the "LGPL" License).
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Please visit http://openfaces.org/licensing/ for more details.
*/

import org.openfaces.test.WebDriverSeleniumTestCase;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import static com.codeborne.selenide.Selenide.$;

/**
* Author: SergeyPensov@teamdev.com
*/
public class Element extends WebDriverSeleniumTestCase {
private String locator;

public Element(String id) {
this.locator = id;
}

public String getId() {
return locator;
}

public boolean isElementInPage(){
try{
driver.findElements(By.id(locator));
return true;
}catch (Exception e){
return false;
}
}

public String toString() {
return "elementByLocator[" + locator + "]";
}

public void click(){
$(this.locator).click();
}
}
@@ -0,0 +1,31 @@
/*
* OpenFaces - JSF Component Library 3.0
* Copyright (C) 2007-2014, TeamDev Ltd.
* licensing@openfaces.org
* Unless agreed in writing the contents of this file are subject to
* the GNU Lesser General Public License Version 2.1 (the "LGPL" License).
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Please visit http://openfaces.org/licensing/ for more details.
*/

package org.openfaces.test.componentInspector;

/**
* Author: SergeyPensov@teamdev.com
*/
public class FoldingPanelInspector extends Element {

private static final String TOGGLE_SUF ="--_defaultButtonsArea--toggle";
public FoldingPanelInspector(String id) {
super(id);
}
public void toggle(){
if(isElementInPage()){
Element toggleButton = new Element(this.getId()+TOGGLE_SUF);
toggleButton.click();
}
}

}
@@ -0,0 +1,45 @@
/*
* OpenFaces - JSF Component Library 3.0
* Copyright (C) 2007-2014, TeamDev Ltd.
* licensing@openfaces.org
* Unless agreed in writing the contents of this file are subject to
* the GNU Lesser General Public License Version 2.1 (the "LGPL" License).
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Please visit http://openfaces.org/licensing/ for more details.
*/

package org.openfaces.test.componentInspector;

import org.openqa.selenium.By;

import java.util.AbstractList;
import java.util.LinkedList;
import java.util.List;

import static com.codeborne.selenide.Selenide.$;

/**
* Author: SergeyPensov@teamdev.com
*/
public class TabSetInspector extends Element {
public TabSetInspector(String id) {
super(id);
}

public List<Element> getTabs() {
int i = 0;
List<Element> tabs = new LinkedList<Element>();
while (true) {
Element tab = new Element(this.getId() + "::" + i);
if ( !tab.isElementInPage())
break;
tabs.add(tab);

}
return tabs;

}

}
@@ -0,0 +1,25 @@
/*
* OpenFaces - JSF Component Library 3.0
* Copyright (C) 2007-2014, TeamDev Ltd.
* licensing@openfaces.org
* Unless agreed in writing the contents of this file are subject to
* the GNU Lesser General Public License Version 2.1 (the "LGPL" License).
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* Please visit http://openfaces.org/licensing/ for more details.
*/

package org.openfaces.test.componentInspector;

/**
* Author: SergeyPensov@teamdev.com
*/
public class TabbedPaneInspector extends Element {
public TabbedPaneInspector(String id) {
super(id);
}
public TabSetInspector tabSet() {
return new TabSetInspector(this.getId() + "--tabSet");
}
}
1 change: 1 addition & 0 deletions webDriverFuncTests/webDriverFuncTests.iml
Expand Up @@ -9,6 +9,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="selenium-webDriver" level="project" />
<orderEntry type="library" name="selenide" level="project" />
</component>
</module>

0 comments on commit e4015a7

Please sign in to comment.