check and uncheck all checkboxes on selectCheckboxMenu using Arquillian Graphene

Posted: March 13, 2013 in web

Page class

 @FindBy(css = "div[id$='filter-state-dropdown_panel']")
 private WebElement stateFilterList;

public void uncheckAllFilterState() {
 toggleAllFilter(stateFilterList, true);
 }

public void checkAllFilterState() {
 toggleAllFilter(stateFilterList, false);
 }

private void toggleAllFilter(WebElement filterElement, boolean isCheckAll) {
 boolean isLoop = true;
 while (isLoop) {
 List<WebElement> dropDownItems = getDropDownItems(filterElement);
 for (WebElement we : dropDownItems) {
 isLoop = false;
 if (we.getAttribute("class").contains("ui-selectcheckboxmenu-checked") && isCheckAll) {
 clickElement(we, GuardType.XHR);
 isLoop = true;
 break;
 }
 }
 }
 }
 private List<WebElement> getDropDownItems(WebElement filterElement) {
 return filterElement.findElements(By.tagName("li"));
 }

Test class

@RunWith(Arquillian.class)
public class TestPageIT extends TestParentIT {

@Before
 public void init() {
 loginPage.submitLogin(VALID_EMAIL, VALID_PASSWORD, GuardType.HTTP);
 quotePage.clickMainNavLink();
 }

@Test
 @OperateOnDeployment(WEBAPP_DEPLOYMENT)
 public void quotes_UncheckedAllStates_NoRatesDisplayed() {
 quotePage.clickCarDropdown();
 quotePage.uncheckAllFilterBody();
 Assert.assertEquals("Cars showing unchecking all filter Body",
 getContentProperty(MESSAGEKEY), quotePage.getNoCarDisplayMessage());
 }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s