Eric Cope
Eric Cope

Reputation: 877

How to Select Multiple Elements with PHPUnit Selenium2 Extension

I want to click on multiple links with the same class using PHPUnit's extension for Selenium2. I am trying to select multiple elements using:

$elements = $this->byClassName('link_class');

However this only selects a single element. How do I select all of my elements and iterate through them?

Upvotes: 0

Views: 704

Answers (1)

Eric Cope
Eric Cope

Reputation: 877

So, with a lot of deep digging I found the answer. All of the high level functions to select elements only use the single element selection strategy. In Session.php (as of 3/3/2013) you can see all of the high level method use

protected function by($strategy, $value)
{
    return $this->element($this->using($strategy)->value($value));
}

I added a small method which uses $this->elements instead of $this->element. Then I was able to iterate through. Good luck!

Upvotes: 1

Related Questions