Skip to content

Commit

Permalink
Merge pull request #1 from wvanderdeijl/master
Browse files Browse the repository at this point in the history
Update from master branch
  • Loading branch information
VincentHuiberts committed Jul 6, 2015
2 parents ce061b7 + 323be6e commit f2555c1
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 98 deletions.
63 changes: 30 additions & 33 deletions RichClientDemoTest/src/com/redheap/selenium/LocatorTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.redheap.selenium;

import com.redheap.selenium.component.AdfDynamicDeclarativeComponent;
import com.redheap.selenium.component.AdfInputText;
import com.redheap.selenium.component.AdfOutputText;
import com.redheap.selenium.component.AdfTable;
import com.redheap.selenium.junit.PageProvider;
import com.redheap.selenium.junit.SavePageSourceOnFailure;
import com.redheap.selenium.junit.ScreenshotOnFailure;
import com.redheap.selenium.junit.WebDriverResource;
import com.redheap.selenium.pages.DeclarativeComponentPage;
import com.redheap.selenium.pages.EditableTablePage;

import java.io.File;
Expand All @@ -30,8 +27,8 @@ public class LocatorTest {
public static WebDriverResource driver = new WebDriverResource();
@Rule
public PageProvider<EditableTablePage> tablePage = new PageProvider(EditableTablePage.class, TABLE_PAGE, driver.getDriver());
@Rule
public PageProvider<DeclarativeComponentPage> declCompPage = new PageProvider(DeclarativeComponentPage.class, DECL_COMP_PAGE, driver.getDriver());
// @Rule
// public PageProvider<DeclarativeComponentPage> declCompPage = new PageProvider(DeclarativeComponentPage.class, DECL_COMP_PAGE, driver.getDriver());
@Rule
public TestWatcher screenshotOnFailure = new ScreenshotOnFailure(driver.getDriver(), new File("errors"));
@Rule
Expand Down Expand Up @@ -63,15 +60,15 @@ public void testRelativeLocatorFromNonNamingContainer() {
assertEquals("dmoTpl:table1:0:it3", target.getClientId());
}

@Test
public void testRelativeLocatorFromNamingContainer() {
EditableTablePage page = tablePage.goHome();
AdfTable table = page.findTable();
AdfDynamicDeclarativeComponent namingContainer = table.findAdfComponentByLocator(":dmoTpl:gTools:glryFind");
AdfInputText target = namingContainer.findAdfComponentByLocator("findIt");
assertEquals("dmoTpl:gTools:glryFind:findIt", target.getAbsoluteLocator());
assertEquals("dmoTpl:gTools:glryFind:findIt", target.getClientId());
}
// @Test
// public void testRelativeLocatorFromNamingContainer() {
// EditableTablePage page = tablePage.goHome();
// AdfTable table = page.findTable();
// AdfDynamicDeclarativeComponent namingContainer = table.findAdfComponentByLocator(":dmoTpl:gTools:glryFind");
// AdfInputText target = namingContainer.findAdfComponentByLocator("findIt");
// assertEquals("dmoTpl:gTools:glryFind:findIt", target.getAbsoluteLocator());
// assertEquals("dmoTpl:gTools:glryFind:findIt", target.getClientId());
// }

@Test
public void testRelativeDifferentIndexLocator() {
Expand Down Expand Up @@ -99,25 +96,25 @@ public void testNonExistingChild() {
assertNull(table.findAdfComponent("foo"));
}

@Test
public void testDeclarativeComponentLocator() {
DeclarativeComponentPage page = declCompPage.goHome();
AdfDynamicDeclarativeComponent declComp = page.findDeclarativeComponent();
AdfOutputText target = declComp.findAdfComponentByLocator("dcot1");
assertEquals("dmoTpl:lwdc:dcot1", target.getAbsoluteLocator());
assertEquals("dmoTpl:lwdc:dcot1", target.getClientId());
// af:ierator does not exist at client, so simple iter:0:item and not iter[0]:item
AdfInputText it0 = declComp.findAdfComponentByLocator("dci1:0:itemsText");
assertEquals("dmoTpl:lwdc:dci1:0:itemsText", it0.getAbsoluteLocator());
assertEquals("dmoTpl:lwdc:dci1:0:itemsText", it0.getClientId());
AdfInputText it2 = declComp.findAdfComponentByLocator("dci1:2:itemsText");
assertEquals("dmoTpl:lwdc:dci1:2:itemsText", it2.getAbsoluteLocator());
assertEquals("dmoTpl:lwdc:dci1:2:itemsText", it2.getClientId());
// facet content
AdfInputText fit = declComp.findAdfComponentByLocator("facetInputText");
assertEquals("dmoTpl:lwdc:facetInputText", fit.getAbsoluteLocator());
assertEquals("dmoTpl:lwdc:facetInputText", fit.getClientId());
}
// @Test
// public void testDeclarativeComponentLocator() {
// DeclarativeComponentPage page = declCompPage.goHome();
// AdfDynamicDeclarativeComponent declComp = page.findDeclarativeComponent();
// AdfOutputText target = declComp.findAdfComponentByLocator("dcot1");
// assertEquals("dmoTpl:lwdc:dcot1", target.getAbsoluteLocator());
// assertEquals("dmoTpl:lwdc:dcot1", target.getClientId());
// // af:ierator does not exist at client, so simple iter:0:item and not iter[0]:item
// AdfInputText it0 = declComp.findAdfComponentByLocator("dci1:0:itemsText");
// assertEquals("dmoTpl:lwdc:dci1:0:itemsText", it0.getAbsoluteLocator());
// assertEquals("dmoTpl:lwdc:dci1:0:itemsText", it0.getClientId());
// AdfInputText it2 = declComp.findAdfComponentByLocator("dci1:2:itemsText");
// assertEquals("dmoTpl:lwdc:dci1:2:itemsText", it2.getAbsoluteLocator());
// assertEquals("dmoTpl:lwdc:dci1:2:itemsText", it2.getClientId());
// // facet content
// AdfInputText fit = declComp.findAdfComponentByLocator("facetInputText");
// assertEquals("dmoTpl:lwdc:facetInputText", fit.getAbsoluteLocator());
// assertEquals("dmoTpl:lwdc:facetInputText", fit.getClientId());
// }

public static void main(String[] args) {
String[] args2 = { LocatorTest.class.getName() };
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.redheap.selenium.components;

import com.redheap.selenium.component.AdfCommandMenuItem;
import com.redheap.selenium.component.AdfMenu;
import com.redheap.selenium.junit.PageProvider;
import com.redheap.selenium.junit.SavePageSourceOnFailure;
import com.redheap.selenium.junit.ScreenshotOnFailure;
import com.redheap.selenium.junit.WebDriverResource;

import com.redheap.selenium.pages.MenuDemoPage;

import java.io.File;

import static org.junit.Assert.*;

import org.junit.Test;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.rules.TestWatcher;

public class MenuTest {

@ClassRule
public static WebDriverResource driver = new WebDriverResource();
@Rule
public PageProvider<MenuDemoPage> pages = new PageProvider(MenuDemoPage.class, HOME_PAGE, driver.getDriver());
@Rule
public TestWatcher screenshotOnFailure = new ScreenshotOnFailure(driver.getDriver(), new File("errors"));
@Rule
public TestWatcher saveSourceOnFailure = new SavePageSourceOnFailure(driver.getDriver(), new File("errors"));

private static final String HOME_PAGE = "http://localhost:7101/adf-richclient-demo/faces/components/menu.jspx";

@Test
public void testDisabledMenu() {
AdfMenu menu = pages.goHome().findDisabledMenu();
assertTrue(menu.isDisabled());
}

@Test
public void testFileMenu() {
MenuDemoPage page = pages.goHome();
AdfMenu menu = page.findFileMenu();
assertTrue(!menu.isDisabled());
assertEquals("File", menu.getElement().getText());
menu.click();
AdfCommandMenuItem closeItem = page.findCloseItem();
assertEquals("Close Ctrl+W", closeItem.getElement().getText());
}

@Test
public void testSubMenuNew() {
MenuDemoPage page = pages.goHome();
AdfMenu menu = page.findFileMenu();
menu.click();
AdfMenu newMenu = page.findNewSubMenu();
assertEquals("New", newMenu.getElement().getText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import java.io.File;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.*;
import org.junit.ClassRule;
Expand All @@ -33,26 +33,54 @@ public class SelectManyChoiceTest {
"http://localhost:7101/adf-richclient-demo/faces/components/selectManyChoice.jspx";

@Test
public void testItemLabels() {
public void testItems() {
AdfSelectManyChoice choice = pages.goHome().findDrinksSelectManyChoice();
assertEquals("coffee", choice.getItemLabel(0));
assertEquals("0", choice.getItemValue(0));
assertEquals(0, choice.getItemIndexByLabel("coffee"));
assertEquals("tea", choice.getItemLabel(1));
// item 2 is rendered=false
assertEquals("fizz", choice.getItemLabel(3));
// item 4 is rendered=false
assertEquals("beer", choice.getItemLabel(5));
assertEquals("lemonade", choice.getItemLabel(6));
assertEquals("1", choice.getItemValue(1));
assertEquals(1, choice.getItemIndexByLabel("tea"));
// milk (value "2") is rendered=false
assertEquals("fizz", choice.getItemLabel(2));
assertEquals("3", choice.getItemValue(2));
assertEquals(2, choice.getItemIndexByLabel("fizz"));
// item "4" is rendered=false
assertEquals("beer", choice.getItemLabel(3));
assertEquals("5", choice.getItemValue(3));
assertEquals(3, choice.getItemIndexByLabel("beer"));
assertEquals("lemonade", choice.getItemLabel(4));
assertEquals("6", choice.getItemValue(4));
assertEquals(4, choice.getItemIndexByLabel("lemonade"));
}

@Test
public void testSetValue() {
AdfSelectManyChoice choice = pages.goHome().findDrinksSelectManyChoice();
choice.clickItemsByIndices(new int[] { 1, 3 });
choice.click();
ArrayList clickedItems = (ArrayList) choice.getValue();
assertEquals(2, clickedItems.size());
assertEquals("1", clickedItems.get(0));
assertEquals("3", clickedItems.get(1));
choice.clickItemsByIndices(1, 3, 4); // idx=3 is disabled so should not work
assertEquals( "tea; lemonade", choice.getContent());
// selected values
List<Object> selectedValues = choice.getValue();
assertEquals(2, selectedValues.size());
assertEquals("1", selectedValues.get(0));
assertEquals("6", selectedValues.get(1));
// selected indices
long[] selectedIndices = choice.getValueIndices();
assertEquals(2, selectedIndices.length);
assertEquals(1, selectedIndices[0]);
assertEquals(4, selectedIndices[1]);
List<String> selectedLabels = choice.getValueLabels();
assertEquals(2, selectedLabels.size());
assertEquals("tea", selectedLabels.get(0));
assertEquals("lemonade", selectedLabels.get(1));
choice.clickItemsByLabels("fizz", "item6");
assertEquals("tea; fizz; lemonade; item6", choice.getContent());
selectedLabels = choice.getValueLabels();
assertEquals(4, selectedLabels.size());
assertEquals("tea", selectedLabels.get(0));
assertEquals("fizz", selectedLabels.get(1));
assertEquals("lemonade", selectedLabels.get(2));
assertEquals("item6", selectedLabels.get(3));
}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.redheap.selenium.pages;

import com.redheap.selenium.component.AdfCommandMenuItem;
import com.redheap.selenium.component.AdfMenu;
import com.redheap.selenium.page.Page;

import org.openqa.selenium.WebDriver;

public class MenuDemoPage extends Page {

private final String fileMenu = "dmoTpl:menu1";
private final String newSubmenu = "dmoTpl:menu2";
private final String disabledMenu = "dmoTpl:menu8";
private final String closeMenuItem = "dmoTpl:cmi9";

public MenuDemoPage(WebDriver webDriver) {
super(webDriver);
}

@Override
protected String getExpectedTitle() {
return "menu Demo";
}

public AdfMenu findFileMenu() {
return findAdfComponent(fileMenu);
}

public AdfCommandMenuItem findCloseItem(){
return findAdfComponent(closeMenuItem);
}

public AdfMenu findNewSubMenu() {
return findAdfComponent(newSubmenu);
}

public AdfMenu findDisabledMenu() {
return findAdfComponent(disabledMenu);
}
}
11 changes: 11 additions & 0 deletions SeleniumTools/src/com/redheap/selenium/component/AdfMenu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.redheap.selenium.component;

import org.openqa.selenium.WebDriver;

public class AdfMenu extends AdfComponent {

public AdfMenu(WebDriver webDriver, String clientId) {
super(webDriver, clientId);
}

}
Loading

0 comments on commit f2555c1

Please sign in to comment.