Using Selenium 2.0 with ChromeDriver for Joomla 3.0 testing

Rate this item
(0 votes)

This notes are free continuation of the earlier blog entry Using Selenium 2.0 with ChromeDriver for testing of Joomla sites.

All site tests were performed on Joomla 3.0.0 backend using Isis standard template and frontend with protostar template. Used testing environment was Chrome browser ver. 22, chromedriver ver.22, NetBeans Java SE ver.7.1.2.

New administrator template Isis simplifies menu access. It is not necessary to use extended clickTwoLevelMenu method as described in earlier blog. Entire code for clicking on second level of menu is simplified as :

public void clickTwoLevelMenu(String level1Text, String level2Text) {

  driver.findElement(By.linkText(level1Text)).click();

  driver.findElement(By.linkText(level2Text)).click();

}

Major obstacle where in changed naming of toolbar buttons, input boxes and redesigned select combo-boxes. Especially select combo is implemented on Isis template with plenty of auxiliary DOM constructs and javascript. Here cannot be used standard Selenium2 code for setting of Select (single item choice) as :

new Select(driver.findElement(By.id("filter_com"))).selectByVisibleText("com_content");

but the same action on Isis template requires quit heavy method :

public boolean setSelectToText(String id, String value) {

  boolean result = Boolean.TRUE;

  if (!value.equals(getSelectedText(id))) {

    result = Boolean.FALSE;

    WebDriverWait wait = new WebDriverWait(driver, 10);

    WebElement el = driver.findElement(By.id(id));

    el.click();

    String dropItem = "//div[@id='" + id + "']/div[@class='chzn-drop']/ul/li[contains(text(),'" + value + "')]";

    WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(dropItem)));

    element.click();

    result = Boolean.TRUE;

  }

  return result;

}

For above shown example the method call have to be :

setSelectToText("filter_com", "com_content");

In the case of multi-choice Select is situation even more complex. When we see the HTML structure for multi-choice Select - here as example Browser Split selection in JotCache plugin :

 

the Select input consist from combination of original tags (on Isis template per default disabled) plus special container which has two parts : 'choices' and 'drop' blocks.Drop block is only accessable when is clicked on select input box.Generally speaking here is plenty of work to migrate Selenium2 tests from Joomla 2.5 to 3.0 framework but tests are reliable performing (using chromedriver 22) both on test site backend and frontend.

Read 1165 times Last modified on Friday, 19 October 2012 13:19
Login to post comments