Purchase Solution

PHP, PHPUnit, XPath

Not what you're looking for?

Ask Custom Question

Function testCountListElements should simply retrieve an array of all list (html tag li) elements on the page and assert that their total count is three. Utilize an XPath expression for retrieving the elements on the page and assertCount() when doing your assertion. XPath expressions starting with a double slash (ie: //) will locate elements regardless of document position.

/**
* Asserts that the count of list elements on the page is equal
* to three utilizing an xpath expression.
*/
public function testCountListElements() {

/**
*My guess, so far. I have only done Java/Junit before.
*$elements = $this->getSession()->element(array('using'=> WebDriver_Container::XPATH, 'value' => '//li*'));
*
*$this->assertCount(3, sizeof($elements));*/

}

If I were doing Java, it would be as below:

List <WebElement> elements = driver.findElements(By.xpath("//li*"));
assertCount(3, elements.size());

It does not matter what the webpage is and we do not net to worry about creating the session or WebDriver (I have that part covered).

I have just never done Php and I am not sure how to handle loading the array via xpath.

Purchase this Solution

Solution Summary

Solution provides two examples that demonstrate how xpath expression can be used to extract all the list (html tag li) elements from a html document/page.

Solution Preview

Since I do not have your existing code where you are trying to use xpath expression, I am providing you with two examples that demonstrate how xpath expression can be used to extract all the list (html tag li) elements from a html document/page.

To test the ...

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic Networking Questions

This quiz consists of some basic networking questions.

Javscript Basics

Quiz on basics of javascript programming language.