-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from rimamdi/master
added AdfMenu component class with initial unit tests
- Loading branch information
Showing
3 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
RichClientDemoTest/src/com/redheap/selenium/components/MenuTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
RichClientDemoTest/src/com/redheap/selenium/pages/MenuDemoPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
SeleniumTools/src/com/redheap/selenium/component/AdfMenu.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |