-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathPHPSikuliBrowser.php
1180 lines (943 loc) · 29.4 KB
/
PHPSikuliBrowser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* PHPSikuliBrowser is an extension to PHPSikuli.
*
* @category PHP
* @package php-sikuli
* @copyright 2013 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/squizlabs/php-sikuli/blob/master/licence.txt BSD Licence
* @link https://github.com/squizlabs/php-sikuli
*/
require_once 'PHPSikuli.php';
class PHPSikuliBrowser extends PHPSikuli
{
/**
* Browser window range object.
*
* @var string
*/
private $_window = NULL;
/**
* Size of the browser window.
*
* @var array
*/
private $_windowSize = NULL;
/**
* The browserid.
*
* @var string
*/
private $_browserid = NULL;
/**
* The location of the top left corner of the page on the screen.
*
* @var array
*/
private $_pageTopLeft = NULL;
/**
* Temporary directory used during script execution.
*
* @var string
*/
private $_tmpDir = NULL;
/**
* Create files and directories with this group.
*
* @var string
*/
private $_fileGroup = NULL;
/**
* List of supported browsers.
*
* @var array
*/
private $_supportedBrowsers = array(
'firefox' => 'Firefox',
'firefoxNightly' => 'FirefoxNightly',
'chrome' => 'Google Chrome',
'chromium' => 'Chromium',
'chromeCanary' => 'Google Chrome Canary',
'safari' => 'Safari',
'ie8' => 'Internet Explorer 8',
'ie9' => 'Internet Explorer 9',
'ie10' => 'Internet Explorer 10',
'ie11' => 'Internet Explorer 11',
'edge' => 'Edge',
);
/**
* Default size of the browser window.
*
* @var array
*/
private $_defaultWindowSize = NULL;
/**
* The delay after a mouse click in milliseconds.
*
* @var integer
*/
private $_clickDelay = 0;
/**
* Default position of the browser window.
*
* @var array
*/
private $_defaultWindowPosition = NULL;
/**
* Setting to keep the browser open.
*
* @var boolean
*/
private $_keepOpen = TRUE;
/**
* Constructor.
*
* @param string $browser The browser to use.
* @param array $settings Settings for PHPSikuliBrowser.
*/
public function __construct($browser, array $settings=array())
{
$this->_tmpDir = dirname(__FILE__).'/tmp';
if (file_exists($this->_tmpDir) === FALSE) {
mkdir($this->_tmpDir, 0770, TRUE);
} else {
// Remove temp files.
$files = glob($this->_tmpDir.'/*.*');
foreach ($files as $file) {
if (is_file($file) === TRUE) {
unlink($file);
}
}
}
$this->_handleSettings($settings);
chmod($this->_tmpDir, 0770);
if ($this->_fileGroup !== NULL) {
chgrp($this->_tmpDir, $this->_fileGroup);
}
parent::__construct();
$this->_setBrowser($browser);
}//end __construct()
/**
* Resets the Sikuli connection.
*
* @return void
*/
public function resetConnection()
{
$this->stopJSPolling();
parent::resetConnection();
$this->_windowSize = NULL;
$this->_setBrowser($this->_browserid);
}//end resetConnection()
/**
* Reloads the page.
*
* @return void
*/
public function reloadPage()
{
$this->_pageTopLeft = NULL;
$this->stopJSPolling();
$this->keyDown('Key.CMD + r');
}//end reloadPage()
/**
* Sets the browser URL to the specified URL.
*
* @param string $url The new URL.
*
* @return void
*/
public function goToURL($url)
{
$this->stopJSPolling();
$this->keyDown('Key.CMD+l');
$this->type($url);
$this->keyDown('Key.ENTER');
sleep(1);
}//end goToURL()
/**
* Type the text at the current focused input field or at a click point specified by PSMRL.
*
* @param string $text The text to type.
* @param string $modifiers Key modifiers.
* @param string $psmrl PSMRL variable.
*
* @return integer
*/
public function type($text, $modifiers=NULL, $psmrl=NULL)
{
// We may need to increase the timeout when typing. It takes about 5s to
// type 100 characters.
$length = strlen($text);
$timeout = (int) (($length * 10) / 100);
$currentTimeout = NULL;
if ($timeout > 10) {
$timeout += 10;
$currentTimeout = $this->setSikuliCMDTimeout($timeout);
}
$result = parent::type($text, $modifiers, $psmrl);
if ($timeout > 10) {
$this->setSikuliCMDTimeout($currentTimeout);
}
return $result;
}//end type()
/**
* Returns the rectangle for a DOM element found using the specified selector.
*
* @param string $selector The jQuery selector to use for finding the element.
* @param integer $index The element index of the resulting array.
* @param boolean $fallbackToVisible If set to true and the element at given index is not visible then the first
* visible element of the selector is returned.
*
* @return array
*/
public function getBoundingRectangle($selector, $index=0, $fallbackToVisible=false)
{
if ($fallbackToVisible === true) {
$fallbackToVisible = 'true';
} else {
$fallbackToVisible = 'false';
}
$selector = addcslashes($selector, '"');
$rect = $this->execJS('PHPSikuliBrowser.getBoundingRectangle("'.$selector.'", '.$index.', '.$fallbackToVisible.')', FALSE);
return $rect;
}//end getBoundingRectangle()
/**
* Clicks the specified location.
*
* @param string $psmrl A Pattern, String, Match, Region or Location.
* @param string $modifiers One or more key modifiers.
*
* @return void
*/
public function click($psmrl, $modifiers=NULL)
{
parent::click($psmrl, $modifiers);
if ($this->_clickDelay > 0) {
usleep($this->_clickDelay * 1000);
}
}//end click()
/**
* Clicks an element in the content.
*
* @param string $selector The jQuery selector to use for finding the element.
* @param integer $index The element index of the resulting array.
* @param boolean $rightClick If TRUE then right mouse button is used.
*
* @return void
*/
public function clickElement($selector, $index=0, $rightClick=FALSE)
{
$region = $this->getElementRegion($selector, $index);
// Click the element.
if ($rightClick !== TRUE) {
$this->click($region);
} else {
$this->rightClick($region);
}
}//end clickElement()
/**
* Clicks an element in the content.
*
* Only the first visible element will be clicked.
*
* @param string $selector The jQuery selector to use for finding the element.
* @param boolean $rightClick If TRUE then right mouse button is used.
*
* @return void
*/
public function clickVisibleElement($selector, $rightClick=FALSE)
{
$region = $this->getElementRegion($selector, 0, true);
// Click the element.
if ($rightClick !== TRUE) {
$this->click($region);
} else {
$this->rightClick($region);
}
}//end clickVisibleElement()
/**
* Returns the region object of the element found using the selector.
*
* @param string $selector The jQuery selector to use for finding the element.
* @param integer $index The element index of the resulting array.
* @param boolean $fallbackToVisible If set to true and the element at given index is not visible then the first
* visible element of the selector is returned.
*
* @return string
*/
public function getElementRegion($selector, $index=0, $fallbackToVisible=false)
{
$elemRect = $this->getBoundingRectangle($selector, $index, $fallbackToVisible);
if ($elemRect === NULL) {
throw new Exception('Element: ['.$selector.']('.$index.') not found!');
}
$region = $this->getRegionOnPage($elemRect);
return $region;
}//end getElementRegion()
/**
* Returns the HTML contents of the found element.
*
* @param string $selector The jQuery selector to use for finding the element.
* @param integer $index The element index of the resulting array.
*
* @return string
*/
public function getHTML($selector, $index=0)
{
$html = $this->execJS('$.find("'.$selector.'")['.$index.'].innerHTML');
return $html;
}//end getHTML()
/**
* Executes the specified JavaScript and returns its result.
*
* @param string $js The JavaScript to execute.
* @param boolean $noReturnValue If TRUE then JS has no return value and NULL
* will be returned to speed up execution.
* @param boolean $raw If TRUE content will not be modified.
*
* @return string
* @throws Exception If there is a Selenium error.
*/
public function execJS($js, $noReturnValue=FALSE, $raw=FALSE)
{
$this->debug('ExecJS: '.$js);
$jsResultPath = $this->_tmpDir.'/jsres.tmp';
clearstatcache();
if (file_exists($jsResultPath) === TRUE) {
unlink($jsResultPath);
}
$maxTry = 20;
do {
if (file_put_contents($this->_tmpDir.'/jsexec.tmp', $js, LOCK_EX) !== FALSE) {
break;
}
usleep(50000);
} while ($maxTry-- > 0);
chmod($this->_tmpDir.'/jsexec.tmp', 0660);
if ($this->_fileGroup !== NULL) {
chgrp($this->_tmpDir.'/jsexec.tmp', $this->_fileGroup);
}
if ($noReturnValue === TRUE) {
usleep(500000);
return NULL;
}
$startTime = microtime(TRUE);
$timeout = 3;
while (file_exists($jsResultPath) === FALSE) {
if ((microtime(TRUE) - $startTime) > $timeout) {
throw new Exception('Browser is not responding!');
}
usleep(50000);
}
$result = file_get_contents($jsResultPath);
unlink($jsResultPath);
if ($result === 'undefined' || trim($result) === '') {
return NULL;
}
$result = json_decode($result, TRUE);
if (is_string($result) === TRUE && $raw !== TRUE) {
$result = str_replace("\r\n", '\n', $result);
$result = str_replace("\n", '\n', $result);
}
return $result;
}//end execJS()
/**
* Stops the JS polling for commands.
*
* @return void
*/
public function stopJSPolling()
{
$this->execJS('PHPSikuliBrowser.stopPolling()', TRUE);
if (file_exists($this->_tmpDir.'/jsres.tmp') === TRUE) {
unlink($this->_tmpDir.'/jsres.tmp');
}
if (file_exists($this->_tmpDir.'/jsexec.tmp') === TRUE) {
unlink($this->_tmpDir.'/jsexec.tmp');
}
}//end stopJSPolling()
/**
* Returns the JS errors.
*
* @return array
*/
public function getJSErrors()
{
$res = $this->execJS('PHPSikuliBrowser.getJSErrors()', FALSE);
return $res;
}//end getJSErrors()
/**
* Returns a new Region object relative to the top left of the test page.
*
* @param array $rect The rectangle (x1, y1, x2, y2).
*
* @return string
*/
public function getRegionOnPage(array $rect)
{
$pageLoc = $this->getPageTopLeft();
$x = (int) ($pageLoc['x'] + $rect['x1']);
$y = (int) ($pageLoc['y'] + $rect['y1']);
$w = (int) ($rect['x2'] - $rect['x1']);
$h = (int) ($rect['y2'] - $rect['y1']);
$region = $this->createRegion($x, $y, $w, $h);
return $region;
}//end getRegionOnPage()
/**
* Returns the given page X location relative to the screen.
*
* @param integer $x The x location relative to the page.
*
* @return integer
*/
public function getPageXRelativeToScreen($x)
{
$pageLoc = $this->getPageTopLeft();
$x = ($pageLoc['x'] + $x);
return $x;
}//end getPageXRelativeToScreen()
/**
* Returns the given page X location relative to the screen.
*
* @param integer $y The x location relative to the page.
*
* @return integer
*/
public function getPageYRelativeToScreen($y)
{
$pageLoc = $this->getPageTopLeft();
$y = ($pageLoc['y'] + $y);
return $y;
}//end getPageYRelativeToScreen()
/**
* Returns the X position of given location relative to the page.
*
* @param string $loc The location variable.
*
* @return integer
*/
public function getPageX($loc)
{
$pageLoc = $this->getPageTopLeft();
$x = ($this->getX($loc) - $pageLoc['x']);
return $x;
}//end getPageX()
/**
* Returns the Y position of given location relative to the page.
*
* @param string $loc The location variable.
*
* @return integer
*/
public function getPageY($loc)
{
$pageLoc = $this->getPageTopLeft();
$y = ($this->getY($loc) - $pageLoc['y']);
return $y;
}//end getPageY()
/**
* Returns the location of the page relative to the screen.
*
* @return array
*/
public function getPageTopLeft()
{
if ($this->_pageTopLeft === NULL) {
// Get the JS to display the window-target icon.
$this->execJS('PHPSikuliBrowser.showTargetIcon()', FALSE);
$targetIcon = $this->find(dirname(__FILE__).'/window-target.png');
$topLeft = $this->getTopLeft($targetIcon);
$loc = array(
'x' => $this->getX($topLeft),
'y' => $this->getY($topLeft),
);
$this->_pageTopLeft = $loc;
$this->execJS('PHPSikuliBrowser.hideTargetIcon()', TRUE);
}
return $this->_pageTopLeft;
}//end getPageTopLeft()
/**
* Sets the browser to be used.
*
* @param string $browser A valid browser id (E.g. firefox).
*
* @return void
* @throws Exception If the specified browser is not supported.
*/
private function _setBrowser($browser)
{
if (isset($this->_supportedBrowsers[$browser]) === FALSE) {
throw new Exception('Browser is not supported');
}
$appName = $this->_getAppName($browser);
if ($this->getOS() === 'windows') {
$this->closeBrowser($appName);
$this->switchApp($appName);
} else {
$this->restartBrowser($appName);
}
$this->_window = $this->_getBrowserWindow($browser);
$this->_browserid = $browser;
$this->addCacheVar($this->_window);
// Position the browser.
$this->position();
// Resize the browser.
$this->resize();
// Reset zoom.
$this->keyDown('Key.CMD + 0');
}//end _setBrowser()
/**
* Returns the window object of the current browser.
*
* @param string $browser A valid browser id (E.g. firefox).
*
* @return Object
*/
private function _getBrowserWindow($browser)
{
$appName = $this->_getAppName($browser);
$win = null;
$app = null;
if ($this->getOS() === 'windows') {
$app = $this->callFunc('App.focusedWindow', array(), NULL, TRUE);
} else {
$app = $this->switchApp($appName);
}
if ($this->getOS() !== 'windows') {
$windowNum = 0;
switch ($appName) {
case 'Google Chrome':
case 'Chromium':
case 'Google Chrome Canary':
$windowNum = 1;
break;
default:
$windowNum = 0;
break;
}
$win = $this->callFunc(
'window',
array($windowNum),
$app,
TRUE
);
} else {
$win = $app;
}//end if
return $win;
}//end _getBrowserWindow()
/**
* Returns the browsers application name.
*
* @param string $browser A valid browser id (E.g. firefox).
*
* @return string
*/
private function _getAppName($browser)
{
$appName = $browser;
if ($this->getOS() === 'windows') {
switch ($appName) {
case 'chrome':
case 'chromium':
case 'chromeCanary':
$appName = 'chrome';
break;
case 'firefox':
case 'firefoxNightly':
$appName = 'firefox';
break;
default:
if (strpos($appName, 'ie') === 0) {
$appName = 'iexplore';
}
break;
}
} else {
$appName = $this->getBrowserName($browser);
}//end if
return $appName;
}//end _getAppName()
/**
* Closes the specified browser or the active browser.
*
* @param string $browserid Id of the browser to close.
*
* @return void
*/
public function closeBrowser($browserid=NULL)
{
if ($this->_keepOpen === TRUE) {
return;
}
switch ($this->getOS()) {
case 'osx':
// Shutdown browser.
exec('pkill -15 -i '.$browserid);
break;
case 'windows':
$taskName = $browserid;
if ($browserid === 'edge') {
$taskName = 'MicrosoftEdge';
} else if (strpos($browserid, 'ie') === 0) {
$taskName = 'iexplore';
}
// Shutdown browser.
exec('taskkill /F /IM '.$taskName.'.exe');
break;
default:
// OS not supported.
break;
}//end switch
sleep(1);
}//end closeBrowser()
/**
* Restarts the browser.
*
* @param string $browserid Id of the browser to restart.
*
* @return void
*/
public function restartBrowser($browserid=NULL)
{
if ($browserid === NULL) {
$browserid = $this->getBrowserid();
}
$this->closeBrowser($browserid);
sleep(3);
$this->startBrowser($browserid);
}//end restartBrowser()
/**
* Starts the browser.
*
* @param string $browserid Id of the browser to start.
*
* @return void
*/
public function startBrowser($browserid=NULL)
{
if ($browserid === NULL) {
$browserid = $this->getBrowserid();
}
switch ($this->getOS()) {
case 'osx':
// Start browser.
$this->keyDown('Key.CMD + Key.SPACE');
$this->type($browserid);
$this->keyDown('Key.ENTER');
break;
case 'windows':
// Start browser.
if ($browserid === 'edge') {
$this->keyDown('Key.WIN + r');
$this->type('microsoft-edge://');
} else {
// Start browser.
$this->keyDown('Key.WIN + r');
$this->keyDown('Key.DELETE');
if (strpos($browserid, 'ie') === 0) {
$browserid = 'iexplore';
}
$this->type($browserid.' about:blank');
}
$this->keyDown('Key.ENTER');
break;
default:
// OS not supported.
break;
}//end switch
// Wait a few seconds for browser to start.
sleep(2);
$this->keyDown('Key.ENTER');
sleep(2);
}//end startBrowser()
/**
* Returns the id of the browser.
*
* @return string
*/
public function getBrowserid()
{
return $this->_browserid;
}//end getBrowserid()
/**
* Returns the name of the current browser.
*
* @param string $browserid Id of the browser.
*
* @return string
*/
public function getBrowserName($browserid=NULL)
{
if ($browserid === NULL) {
$browserid = $this->getBrowserid();
}
return $this->_supportedBrowsers[$browserid];
}//end getBrowserName()
/**
* Switches to the specifed application.
*
* @param string $name The name of the application to switch to.
*
* @return string
*/
public function switchApp($name)
{
if ($this->getOS() !== 'windows') {
return parent::switchApp($name);
} else if ($name === 'edge') {
$this->keyDown('Key.WIN + r');
$this->type('microsoft-edge://');
} else {
$this->keyDown('Key.WIN + r');
$this->keyDown('Key.DELETE');
$this->type($name.' about:blank');
}
$this->keyDown('Key.ENTER');
sleep(2);
return $this->callFunc('App.focusedWindow', array(), NULL, TRUE);
}//end switchApp()
/**
* Returns the default browser window size.
*
* @return array
*/
public function getDefaultWindowSize()
{
return $this->_defaultWindowSize;
}//end getDefaultWindowSize()
/**
* Set the default browser window size.
*
* @param integer $w The width of the window.
* @param integer $h The height of the window.
*
* @return void
*/
public function setDefaultWindowSize($w, $h)
{
$this->_defaultWindowSize = array(
'w' => $w,
'h' => $h,
);
}//end setDefaultWindowSize()
/**
* Set the default browser window size.
*
* @param integer $x The X position.
* @param integer $y The Y position.
*
* @return void
*/
public function setPosition($x, $y)
{
$this->_defaultWindowPosition = array(
'x' => $x,
'y' => $y,
);
}//end setPosition()
/**
* Position the browser window.
*
* @param integer $x The X position.
* @param integer $y The Y position.
*
* @return void
*/
public function position($x=NULL, $y=NULL)
{
if ($x === NULL || $y === NULL) {
$pos = $this->_defaultWindowPosition;
if ($pos === NULL) {
return;
}
if ($x === NULL) {
$x = $pos['x'];
}
if ($y === NULL) {
$y = $pos['y'];
}
}//end if
$window = $this->getBrowserWindow();
$topLeft = $this->getTopLeft($window);
if ($this->getX($topLeft) === $x && ($this->getY($topLeft) + 10) === $y) {
return;
}
$topRight = $this->getTopRight($window);
$yOffset = 5;
$xOffset = ($this->getX($topRight) - $this->getX($topLeft) - 250);
$start = $this->createLocation(
($this->getX($topLeft) + $xOffset),
($this->getY($topLeft) + $yOffset + 10)
);
$endX = $x + $xOffset;
$endY = $y + $yOffset;
$end = $this->createLocation(
$endX,
$endY
);
$this->dragDrop($start, $end);
$size = $this->getWindowSize();
$this->removeCacheVar($this->_window);
$this->_window = $this->_getBrowserWindow($this->_browserid);
$this->addCacheVar($this->_window);
// Set the default region of the find operations.
$this->setDefaultRegion($this->_window);
}//end position()
/**
* Resizes the browser window.
*
* @param integer $w The width of the window.
* @param integer $h The height of the window.
*
* @return void
*/
public function resize($w=NULL, $h=NULL)
{
if ($w === NULL || $h === NULL) {
$size = $this->getDefaultWindowSize();
if ($size === NULL) {
return;
}
if ($w === NULL) {