1: <?php
2: namespace Azalea\Selenium\App\Components;
3:
4: use Azalea\Selenium\Toolkit\View;
5:
6: class CollectionGrid extends View
7: {
8: 9: 10: 11: 12: 13:
14: public function first()
15: {
16: return $this->at(0);
17: }
18:
19: 20: 21: 22: 23: 24: 25:
26: public function at($index)
27: {
28: return $this->filter('[data-grid-row="'.$index.'"]');
29: }
30:
31: 32: 33: 34: 35:
36: public function count()
37: {
38: $rows = $this->querySelectorAll('[data-grid-row]');
39: return count($rows);
40: }
41:
42: 43: 44:
45: public function waitForRowAt($index)
46: {
47: return $this->waitFor('[data-grid-row="'.$index.'"]');
48: }
49:
50: 51: 52:
53: public function waitForRowTextAt($index, $text)
54: {
55: $self = $this;
56: $this->driver->spinWait(function () use ($self, $index, $text) {
57: return $self->at($index)->see($text);
58: });
59: return $this;
60: }
61:
62: 63: 64:
65: public function waitForRowElementAt($index, $selector)
66: {
67: return $this->waitFor('[data-grid-row="'.$index.'"] '.$selector);
68: }
69:
70: 71: 72:
73: public function waitForModelId($modelId)
74: {
75: return $this->waitFor('[data-model-id="'.$modelId.'"]');
76: }
77:
78: 79: 80:
81: public function waitForRowCount($count)
82: {
83: $self = $this;
84: $this->driver->spinWait(function () use ($self, $count) {
85: return ($self->count() == $count);
86: });
87: return $this;
88: }
89:
90: 91: 92:
93: public function waitForEmpty()
94: {
95: return $this->waitForRowCount(0);
96: }
97: }
98:
99: ?>