Skip to content

Commit

Permalink
Merge pull request #15 from rimamdi/master
Browse files Browse the repository at this point in the history
added AdfMenu component class with initial unit tests
  • Loading branch information
wvanderdeijl committed Jun 25, 2015
2 parents c536577 + 10d2803 commit 867ced4
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
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
@@ -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);
}

}

0 comments on commit 867ced4

Please sign in to comment.