Using Selenium 2.0 with ChromeDriver for testing of Joomla sites

Rate this item
(1 Vote)

Two years testing Joomla extensions with Selenium 1.0 and Firefox browser with necessary plugins showed positive impressions what concerns application web testing but also some obstacles with problematic stability of whole arrangement. When new Selenium 2.0 was public presented I expected faster coding of test cases, higher stability of test runs and better PHP test environment.
But the reality was something other. For Selenium 2.0 best programming is available in Java (fortunatelly more years used as my main programming language) and all old tests were necessary to transform in new Java coding. Test run stability with Firefox (especially when are used several instances of FF) and Selenium server was low promissing only steady troubles. Then switch to Chrome browser / Chrome Driver was bringing necessary reliability to the testing.

With test environment using NetBeans 7, Java SE 6 and Chrome was possible to start quite reasonable Joomla web testing. During testing on Administrator backend was recognized that ChromeDriver has sometimes problem correct open main menu items in second and third level as well as to process pop-up alerts (e.g. when deleting some items from item list). Here are usefull solutions for these cases (as methods of arbitrary WebDriverUtilities class) :

public WebDriverUtilities(WebDriver driver) {

....

public void clickTwoLevelMenu(String level1Text, String level2Text) {

   WebElement el = driver.findElement(By.xpath("//a[text()='" + level1Text + "']"));

   Actions acts = new Actions(driver);

   Action clickElement = acts.moveToElement(el).sendKeys(Keys.ENTER).build();

   clickElement.perform();

   while (!driver.findElement(By.xpath("//a[text()='" + level2Text + "']")).isDisplayed()) {

     try {

       Thread.sleep(200);

     } catch (InterruptedException ex) {

       Logger.getLogger(WebDriverUtilities.class.getName()).log(Level.SEVERE, null, ex);

     }

   }

   driver.findElement(By.xpath("//a[text()='" + level2Text + "']")).click();

}

public void clickThreeLevelMenu(String level1Text, String level2Text, String level3Text) {

   WebElement el = driver.findElement(By.xpath("//a[text()='" + level1Text + "']"));

   WebElement el2 = driver.findElement(By.xpath("//a[text()='" + level2Text + "']"));

   Actions acts = new Actions(driver);

   Action clickElement = acts.moveToElement(el).sendKeys(Keys.ENTER).build();

   clickElement.perform();

   while (!driver.findElement(By.xpath("//a[text()='" + level2Text + "']")).isDisplayed()) {

     try {

       Thread.sleep(200);

     } catch (InterruptedException ex) {

       Logger.getLogger(WebDriverUtilities.class.getName()).log(Level.SEVERE, null, ex);

     }

   }

   clickElement = acts.moveToElement(el2).sendKeys(Keys.ENTER).build();

   clickElement.perform();

   while (!driver.findElement(By.xpath("//a[text()='" + level3Text + "']")).isDisplayed()) {

     try {

       Thread.sleep(100);

     } catch (InterruptedException ex) {

       Logger.getLogger(WebDriverUtilities.class.getName()).log(Level.SEVERE, null, ex);

     }

   }

   driver.findElement(By.xpath("//a[text()='" + level3Text + "']")).click();

}

public void deleteItemsWithAlert() {

   ...................

   driver.findElement(By.cssSelector("span.icon-32-delete")).click();

   System.out.println("alert text: " + driver.switchTo().alert().getText());

   driver.switchTo().alert().accept();

   assertEquals(admin.def[3], driver.getTitle());

}

}

Read 1540 times Last modified onMonday, 11 March 2013 11:42

Only registred users have rights to post comments. Please log-in or create an account.

We have 121 guests and no members online
Copyright © 2015 JotComponents
We have 121 guests and no members online
Copyright © 2017 JotComponents