001 // Copyright 2007, 2008, 2009 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry5.test;
016
017 import com.thoughtworks.selenium.CommandProcessor;
018 import com.thoughtworks.selenium.DefaultSelenium;
019 import com.thoughtworks.selenium.HttpCommandProcessor;
020 import com.thoughtworks.selenium.Selenium;
021 import org.openqa.selenium.server.RemoteControlConfiguration;
022 import org.openqa.selenium.server.SeleniumServer;
023 import org.testng.Assert;
024 import org.testng.ITestContext;
025 import org.testng.annotations.AfterClass;
026 import org.testng.annotations.BeforeClass;
027
028 /**
029 * A base class for creating integration tests. Ths encapsulates starting up an in-process copy of
030 * Jetty, and in-process
031 * copy of {@link SeleniumServer}, and a Selenium client.
032 * <p/>
033 * Unless you are <em>very, very clever</em>, you will want to run the tests sequentially. TestNG
034 * tends to run them in an arbitrary order unless you explicitly set the order. If you have managed
035 * to get TestNG to run tests in parallel, you may see further problems caused by a single client
036 * jumping all over your web application in an unpredictable order.
037 * <p/>
038 * This class implements the {@link Selenium} interface, and delegates all those methods to the
039 * {@link DefaultSelenium} instance it creates. It also extends the normal exception reporting for
040 * any failed command or query to produce a more detailed report to the main console.
041 *
042 * @see org.apache.tapestry5.test.JettyRunner
043 * @deprecated Use {@link SeleniumLauncher} and {@link SeleniumTestCase} instead.
044 */
045 public class AbstractIntegrationTestSuite extends Assert implements Selenium
046 {
047 /**
048 * Default directory containing the web application to be tested (this conforms to Maven's
049 * default folder).
050 */
051 public static final String DEFAULT_WEB_APP_ROOT = "src/main/webapp";
052
053 /**
054 * Default browser in which to run tests - firefox
055 */
056 public static final String DEFAULT_WEB_BROWSER_COMMAND = "*firefox";
057
058 /**
059 * 15 seconds
060 */
061 public static final String PAGE_LOAD_TIMEOUT = "15000";
062
063 /**
064 * The port on which the internal copy of Jetty is executed.
065 */
066 public static final int JETTY_PORT = 9999;
067
068 // This is likely to be a problem, since may want to test with a context path, rather than as
069 // root.
070 public static final String BASE_URL = String.format("http://localhost:%d/", JETTY_PORT);
071
072 public static final String SUBMIT = "//input[@type='submit']";
073
074 private String webappRoot;
075
076 private final String seleniumBrowserCommand;
077
078 private JettyRunner jettyRunner;
079
080 private Selenium selenium;
081
082 private SeleniumServer server;
083
084 private String[] virtualHosts;
085
086 /**
087 * Initializes the suite using {@link #DEFAULT_WEB_APP_ROOT}.
088 */
089 public AbstractIntegrationTestSuite()
090 {
091 this(DEFAULT_WEB_APP_ROOT, DEFAULT_WEB_BROWSER_COMMAND, new String[0]);
092 }
093
094 /**
095 * @param webAppRoot
096 * the directory containing the web application to be tested.
097 */
098 protected AbstractIntegrationTestSuite(String webAppRoot)
099 {
100 this(webAppRoot, DEFAULT_WEB_BROWSER_COMMAND);
101 }
102
103 /**
104 * @param webAppRoot
105 * web application root (default src/main/webapp)
106 * @param browserCommand
107 * browser command to pass to selenium. Default is *firefox, syntax for custom
108 * browsers is
109 * *custom <path_to_browser>, e.g. *custom /usr/lib/mozilla-firefox/firefox
110 * @param virtualHosts
111 * an array with virtual hosts
112 */
113 protected AbstractIntegrationTestSuite(String webAppRoot, String browserCommand,
114 String... virtualHosts)
115 {
116 webappRoot = webAppRoot;
117 seleniumBrowserCommand = browserCommand;
118 this.virtualHosts = virtualHosts;
119 }
120
121 protected final void assertSourcePresent(String... expected)
122 {
123 String source = selenium.getHtmlSource();
124
125 for (String snippet : expected)
126 {
127 if (source.contains(snippet))
128 continue;
129
130 System.err.printf("Source content '%s' not found in:\n%s\n\n", snippet, source);
131
132 throw new AssertionError("Page did not contain source '" + snippet + "'.");
133 }
134 }
135
136 /**
137 * Used when the locator identifies an attribute, not an element.
138 *
139 * @param locator
140 * identifies the attribute whose value is to be asserted
141 * @param expected
142 * expected value for the attribute
143 */
144 protected final void assertAttribute(String locator, String expected)
145 {
146 String actual = null;
147
148 try
149 {
150 actual = getAttribute(locator);
151 }
152 catch (RuntimeException ex)
153 {
154 System.err.printf("Error accessing %s: %s, in:\n\n%s\n\n", locator, ex.getMessage(),
155 selenium.getHtmlSource());
156
157 throw ex;
158 }
159
160 if (actual.equals(expected))
161 return;
162
163 System.err.printf("Text for attribute %s should be '%s' but is '%s', in:\n\n%s\n\n",
164 locator, expected, actual, getHtmlSource());
165
166 throw new AssertionError(String.format("%s was '%s' not '%s'", locator, actual, expected));
167 }
168
169 /**
170 * Asserts the text of an element, identified by the locator.
171 *
172 * @param locator
173 * identifies the element whose text value is to be asserted
174 * @param expected
175 * expected value for the element's text
176 */
177 protected final void assertText(String locator, String expected)
178 {
179 String actual = null;
180
181 try
182 {
183 actual = getText(locator);
184 }
185 catch (RuntimeException ex)
186 {
187 System.err.printf("Error accessing %s: %s, in:\n\n%s\n\n", locator, ex.getMessage(),
188 selenium.getHtmlSource());
189
190 throw ex;
191 }
192
193 if (actual.equals(expected))
194 return;
195
196 System.err.printf("Text for %s should be '%s' but is '%s', in:\n\n%s\n\n", locator,
197 expected, actual, getHtmlSource());
198
199 throw new AssertionError(String.format("%s was '%s' not '%s'", locator, actual, expected));
200 }
201
202 protected final void assertTextPresent(String... text)
203 {
204 for (String item : text)
205 {
206 if (isTextPresent(item))
207 continue;
208
209 System.err.printf("Text pattern '%s' not found in:\n%s\n\n", item, selenium
210 .getHtmlSource());
211
212 throw new AssertionError("Page did not contain '" + item + "'.");
213 }
214 }
215
216 protected final void assertFieldValue(String locator, String expected)
217 {
218 try
219 {
220 assertEquals(getValue(locator), expected);
221 }
222 catch (AssertionError ex)
223 {
224 System.err.printf("%s:\n%s\n\n", ex.getMessage(), selenium.getHtmlSource());
225
226 throw ex;
227 }
228 }
229
230 protected final void clickAndWait(String link)
231 {
232 click(link);
233 waitForPageToLoad(PAGE_LOAD_TIMEOUT);
234 }
235
236 protected final void assertTextSeries(String idFormat, int startIndex, String... values)
237 {
238 for (int i = 0; i < values.length; i++)
239 {
240 String id = String.format(idFormat, startIndex + i);
241
242 assertText(id, values[i]);
243 }
244 }
245
246 protected final void assertAttributeSeries(String idFormat, int startIndex, String... values)
247 {
248 for (int i = 0; i < values.length; i++)
249 {
250 String id = String.format(idFormat, startIndex + i);
251
252 assertAttribute(id, values[i]);
253 }
254 }
255
256 protected final void assertFieldValueSeries(String idFormat, int startIndex, String... values)
257 {
258 for (int i = 0; i < values.length; i++)
259 {
260 String id = String.format(idFormat, startIndex + i);
261
262 assertFieldValue(id, values[i]);
263 }
264 }
265
266 protected void waitForCSSSelectedElementToAppear(String cssRule)
267 {
268 String condition = String.format(
269 "selenium.browserbot.getCurrentWindow().$$(\"%s\").size() > 0", cssRule);
270
271 waitForCondition(condition, PAGE_LOAD_TIMEOUT);
272
273 }
274
275 @AfterClass(alwaysRun = true)
276 public void cleanup() throws Exception
277 {
278 if (selenium != null)
279 {
280 selenium.stop();
281 selenium = null;
282 }
283
284 if (server != null)
285 {
286 server.stop();
287 server = null;
288 }
289
290 if (jettyRunner != null)
291 {
292 jettyRunner.stop();
293 jettyRunner = null;
294 }
295 }
296
297 @BeforeClass(alwaysRun = true)
298 public void setup(ITestContext testContext) throws Exception
299 {
300 jettyRunner = new JettyRunner(TapestryTestConstants.MODULE_BASE_DIR, "/", JETTY_PORT,
301 webappRoot, virtualHosts);
302
303 server = new SeleniumServer();
304
305 server.start();
306
307 CommandProcessor cp = new HttpCommandProcessor("localhost",
308 RemoteControlConfiguration.DEFAULT_PORT, seleniumBrowserCommand, BASE_URL);
309
310 ErrorReporter errorReporter = new ErrorReporterImpl(cp, testContext);
311
312 selenium = new DefaultSelenium(new ErrorReportingCommandProcessor(cp, errorReporter));
313
314 selenium.start();
315 }
316
317 public void start()
318 {
319 selenium.start();
320 }
321
322 public void stop()
323 {
324 selenium.stop();
325 }
326
327 public void click(String locator)
328 {
329 selenium.click(locator);
330 }
331
332 public void doubleClick(String locator)
333 {
334 selenium.doubleClick(locator);
335 }
336
337 public void contextMenu(String locator)
338 {
339 selenium.contextMenu(locator);
340 }
341
342 public void clickAt(String locator, String coordString)
343 {
344 selenium.clickAt(locator, coordString);
345 }
346
347 public void doubleClickAt(String locator, String coordString)
348 {
349 selenium.doubleClickAt(locator, coordString);
350 }
351
352 public void contextMenuAt(String locator, String coordString)
353 {
354 selenium.contextMenuAt(locator, coordString);
355 }
356
357 public void fireEvent(String locator, String eventName)
358 {
359 selenium.fireEvent(locator, eventName);
360 }
361
362 public void focus(String locator)
363 {
364 selenium.focus(locator);
365 }
366
367 public void keyPress(String locator, String keySequence)
368 {
369 selenium.keyPress(locator, keySequence);
370 }
371
372 public void shiftKeyDown()
373 {
374 selenium.shiftKeyDown();
375 }
376
377 public void shiftKeyUp()
378 {
379 selenium.shiftKeyUp();
380 }
381
382 public void metaKeyDown()
383 {
384 selenium.metaKeyDown();
385 }
386
387 public void metaKeyUp()
388 {
389 selenium.metaKeyUp();
390 }
391
392 public void altKeyDown()
393 {
394 selenium.altKeyDown();
395 }
396
397 public void altKeyUp()
398 {
399 selenium.altKeyUp();
400 }
401
402 public void controlKeyDown()
403 {
404 selenium.controlKeyDown();
405 }
406
407 public void controlKeyUp()
408 {
409 selenium.controlKeyUp();
410 }
411
412 public void keyDown(String locator, String keySequence)
413 {
414 selenium.keyDown(locator, keySequence);
415 }
416
417 public void keyUp(String locator, String keySequence)
418 {
419 selenium.keyUp(locator, keySequence);
420 }
421
422 public void mouseOver(String locator)
423 {
424 selenium.mouseOver(locator);
425 }
426
427 public void mouseOut(String locator)
428 {
429 selenium.mouseOut(locator);
430 }
431
432 public void mouseDown(String locator)
433 {
434 selenium.mouseDown(locator);
435 }
436
437 public void mouseDownAt(String locator, String coordString)
438 {
439 selenium.mouseDownAt(locator, coordString);
440 }
441
442 public void mouseUp(String locator)
443 {
444 selenium.mouseUp(locator);
445 }
446
447 public void mouseUpAt(String locator, String coordString)
448 {
449 selenium.mouseUpAt(locator, coordString);
450 }
451
452 public void mouseMove(String locator)
453 {
454 selenium.mouseMove(locator);
455 }
456
457 public void mouseMoveAt(String locator, String coordString)
458 {
459 selenium.mouseMoveAt(locator, coordString);
460 }
461
462 public void type(String locator, String value)
463 {
464 selenium.type(locator, value);
465 }
466
467 public void typeKeys(String locator, String value)
468 {
469 selenium.typeKeys(locator, value);
470 }
471
472 public void setSpeed(String value)
473 {
474 selenium.setSpeed(value);
475 }
476
477 public String getSpeed()
478 {
479 return selenium.getSpeed();
480 }
481
482 public void check(String locator)
483 {
484 selenium.check(locator);
485 }
486
487 public void uncheck(String locator)
488 {
489 selenium.uncheck(locator);
490 }
491
492 public void select(String selectLocator, String optionLocator)
493 {
494 selenium.select(selectLocator, optionLocator);
495 }
496
497 public void addSelection(String locator, String optionLocator)
498 {
499 selenium.addSelection(locator, optionLocator);
500 }
501
502 public void removeSelection(String locator, String optionLocator)
503 {
504 selenium.removeSelection(locator, optionLocator);
505 }
506
507 public void removeAllSelections(String locator)
508 {
509 selenium.removeAllSelections(locator);
510 }
511
512 public void submit(String formLocator)
513 {
514 selenium.submit(formLocator);
515 }
516
517 public void open(String url)
518 {
519 // open the URL but ignore the HTTP status code. Necessary if we want to check
520 // for certain contents on error pages. The behaviour changed in Selenium 1.0.2.
521 // Until then the HTTP status code was just ignored.
522 selenium.open(url, "true");
523 }
524
525 public void openWindow(String url, String windowID)
526 {
527 selenium.openWindow(url, windowID);
528 }
529
530 public void selectWindow(String windowID)
531 {
532 selenium.selectWindow(windowID);
533 }
534
535 public void selectFrame(String locator)
536 {
537 selenium.selectFrame(locator);
538 }
539
540 public boolean getWhetherThisFrameMatchFrameExpression(String currentFrameString, String target)
541 {
542 return selenium.getWhetherThisFrameMatchFrameExpression(currentFrameString, target);
543 }
544
545 public boolean getWhetherThisWindowMatchWindowExpression(String currentWindowString,
546 String target)
547 {
548 return selenium.getWhetherThisWindowMatchWindowExpression(currentWindowString, target);
549 }
550
551 /**
552 * Waits the default time for the page to load.
553 */
554 public void waitForPageToLoad()
555 {
556 waitForPageToLoad(PAGE_LOAD_TIMEOUT);
557 }
558
559 public void waitForPopUp(String windowID, String timeout)
560 {
561 selenium.waitForPopUp(windowID, timeout);
562 }
563
564 public void chooseCancelOnNextConfirmation()
565 {
566 selenium.chooseCancelOnNextConfirmation();
567 }
568
569 public void chooseOkOnNextConfirmation()
570 {
571 selenium.chooseOkOnNextConfirmation();
572 }
573
574 public void answerOnNextPrompt(String answer)
575 {
576 selenium.answerOnNextPrompt(answer);
577 }
578
579 public void goBack()
580 {
581 selenium.goBack();
582 }
583
584 public void refresh()
585 {
586 selenium.refresh();
587 }
588
589 public void close()
590 {
591 selenium.close();
592 }
593
594 public boolean isAlertPresent()
595 {
596 return selenium.isAlertPresent();
597 }
598
599 public boolean isPromptPresent()
600 {
601 return selenium.isPromptPresent();
602 }
603
604 public boolean isConfirmationPresent()
605 {
606 return selenium.isConfirmationPresent();
607 }
608
609 public String getAlert()
610 {
611 return selenium.getAlert();
612 }
613
614 public String getConfirmation()
615 {
616 return selenium.getConfirmation();
617 }
618
619 public String getPrompt()
620 {
621 return selenium.getPrompt();
622 }
623
624 public String getLocation()
625 {
626 return selenium.getLocation();
627 }
628
629 public String getTitle()
630 {
631 return selenium.getTitle();
632 }
633
634 public String getBodyText()
635 {
636 return selenium.getBodyText();
637 }
638
639 public String getValue(String locator)
640 {
641 return selenium.getValue(locator);
642 }
643
644 public String getText(String locator)
645 {
646 return selenium.getText(locator);
647 }
648
649 public void highlight(String locator)
650 {
651 selenium.highlight(locator);
652 }
653
654 public String getEval(String script)
655 {
656 return selenium.getEval(script);
657 }
658
659 public boolean isChecked(String locator)
660 {
661 return selenium.isChecked(locator);
662 }
663
664 public String getTable(String tableCellAddress)
665 {
666 return selenium.getTable(tableCellAddress);
667 }
668
669 public String[] getSelectedLabels(String selectLocator)
670 {
671 return selenium.getSelectedLabels(selectLocator);
672 }
673
674 public String getSelectedLabel(String selectLocator)
675 {
676 return selenium.getSelectedLabel(selectLocator);
677 }
678
679 public String[] getSelectedValues(String selectLocator)
680 {
681 return selenium.getSelectedValues(selectLocator);
682 }
683
684 public String getSelectedValue(String selectLocator)
685 {
686 return selenium.getSelectedValue(selectLocator);
687 }
688
689 public String[] getSelectedIndexes(String selectLocator)
690 {
691 return selenium.getSelectedIndexes(selectLocator);
692 }
693
694 public String getSelectedIndex(String selectLocator)
695 {
696 return selenium.getSelectedIndex(selectLocator);
697 }
698
699 public String[] getSelectedIds(String selectLocator)
700 {
701 return selenium.getSelectedIds(selectLocator);
702 }
703
704 public String getSelectedId(String selectLocator)
705 {
706 return selenium.getSelectedId(selectLocator);
707 }
708
709 public boolean isSomethingSelected(String selectLocator)
710 {
711 return selenium.isSomethingSelected(selectLocator);
712 }
713
714 public String[] getSelectOptions(String selectLocator)
715 {
716 return selenium.getSelectOptions(selectLocator);
717 }
718
719 public String getAttribute(String attributeLocator)
720 {
721 return selenium.getAttribute(attributeLocator);
722 }
723
724 public boolean isTextPresent(String pattern)
725 {
726 return selenium.isTextPresent(pattern);
727 }
728
729 public boolean isElementPresent(String locator)
730 {
731 return selenium.isElementPresent(locator);
732 }
733
734 public boolean isVisible(String locator)
735 {
736 return selenium.isVisible(locator);
737 }
738
739 public boolean isEditable(String locator)
740 {
741 return selenium.isEditable(locator);
742 }
743
744 public String[] getAllButtons()
745 {
746 return selenium.getAllButtons();
747 }
748
749 public String[] getAllLinks()
750 {
751 return selenium.getAllLinks();
752 }
753
754 public String[] getAllFields()
755 {
756 return selenium.getAllFields();
757 }
758
759 public String[] getAttributeFromAllWindows(String attributeName)
760 {
761 return selenium.getAttributeFromAllWindows(attributeName);
762 }
763
764 public void dragdrop(String locator, String movementsString)
765 {
766 selenium.dragdrop(locator, movementsString);
767 }
768
769 public void setMouseSpeed(String pixels)
770 {
771 selenium.setMouseSpeed(pixels);
772 }
773
774 public Number getMouseSpeed()
775 {
776 return selenium.getMouseSpeed();
777 }
778
779 public void dragAndDrop(String locator, String movementsString)
780 {
781 selenium.dragAndDrop(locator, movementsString);
782 }
783
784 public void dragAndDropToObject(String locatorOfObjectToBeDragged,
785 String locatorOfDragDestinationObject)
786 {
787 selenium.dragAndDropToObject(locatorOfObjectToBeDragged, locatorOfDragDestinationObject);
788 }
789
790 public void windowFocus()
791 {
792 selenium.windowFocus();
793 }
794
795 public void windowMaximize()
796 {
797 selenium.windowMaximize();
798 }
799
800 public String[] getAllWindowIds()
801 {
802 return selenium.getAllWindowIds();
803 }
804
805 public String[] getAllWindowNames()
806 {
807 return selenium.getAllWindowNames();
808 }
809
810 public String[] getAllWindowTitles()
811 {
812 return selenium.getAllWindowTitles();
813 }
814
815 public String getHtmlSource()
816 {
817 return selenium.getHtmlSource();
818 }
819
820 public void setCursorPosition(String locator, String position)
821 {
822 selenium.setCursorPosition(locator, position);
823 }
824
825 public Number getElementIndex(String locator)
826 {
827 return selenium.getElementIndex(locator);
828 }
829
830 public boolean isOrdered(String locator1, String locator2)
831 {
832 return selenium.isOrdered(locator1, locator2);
833 }
834
835 public Number getElementPositionLeft(String locator)
836 {
837 return selenium.getElementPositionLeft(locator);
838 }
839
840 public Number getElementPositionTop(String locator)
841 {
842 return selenium.getElementPositionTop(locator);
843 }
844
845 public Number getElementWidth(String locator)
846 {
847 return selenium.getElementWidth(locator);
848 }
849
850 public Number getElementHeight(String locator)
851 {
852 return selenium.getElementHeight(locator);
853 }
854
855 public Number getCursorPosition(String locator)
856 {
857 return selenium.getCursorPosition(locator);
858 }
859
860 public String getExpression(String expression)
861 {
862 return selenium.getExpression(expression);
863 }
864
865 public Number getXpathCount(String xpath)
866 {
867 return selenium.getXpathCount(xpath);
868 }
869
870 public void assignId(String locator, String identifier)
871 {
872 selenium.assignId(locator, identifier);
873 }
874
875 public void allowNativeXpath(String allow)
876 {
877 selenium.allowNativeXpath(allow);
878 }
879
880 public void ignoreAttributesWithoutValue(String ignore)
881 {
882 selenium.ignoreAttributesWithoutValue(ignore);
883 }
884
885 public void waitForCondition(String script, String timeout)
886 {
887 selenium.waitForCondition(script, timeout);
888 }
889
890 public void setTimeout(String timeout)
891 {
892 selenium.setTimeout(timeout);
893 }
894
895 public void waitForPageToLoad(String timeout)
896 {
897 selenium.waitForPageToLoad(timeout);
898 }
899
900 public void waitForFrameToLoad(String frameAddress, String timeout)
901 {
902 selenium.waitForFrameToLoad(frameAddress, timeout);
903 }
904
905 public String getCookie()
906 {
907 return selenium.getCookie();
908 }
909
910 public String getCookieByName(String name)
911 {
912 return selenium.getCookieByName(name);
913 }
914
915 public boolean isCookiePresent(String name)
916 {
917 return selenium.isCookiePresent(name);
918 }
919
920 public void createCookie(String nameValuePair, String optionsString)
921 {
922 selenium.createCookie(nameValuePair, optionsString);
923 }
924
925 public void deleteCookie(String name, String optionsString)
926 {
927 selenium.deleteCookie(name, optionsString);
928 }
929
930 public void deleteAllVisibleCookies()
931 {
932 selenium.deleteAllVisibleCookies();
933 }
934
935 public void setBrowserLogLevel(String logLevel)
936 {
937 selenium.setBrowserLogLevel(logLevel);
938 }
939
940 public void runScript(String script)
941 {
942 selenium.runScript(script);
943 }
944
945 public void addLocationStrategy(String strategyName, String functionDefinition)
946 {
947 selenium.addLocationStrategy(strategyName, functionDefinition);
948 }
949
950 public void setContext(String context)
951 {
952 selenium.setContext(context);
953 }
954
955 public void attachFile(String fieldLocator, String fileLocator)
956 {
957 selenium.attachFile(fieldLocator, fileLocator);
958 }
959
960 public void captureScreenshot(String filename)
961 {
962 selenium.captureScreenshot(filename);
963 }
964
965 public void shutDownSeleniumServer()
966 {
967 selenium.shutDownSeleniumServer();
968 }
969
970 public void keyDownNative(String keycode)
971 {
972 selenium.keyDownNative(keycode);
973 }
974
975 public void keyUpNative(String keycode)
976 {
977 selenium.keyUpNative(keycode);
978 }
979
980 public void keyPressNative(String keycode)
981 {
982 selenium.keyPressNative(keycode);
983 }
984
985 /**
986 * Used to start a typical test, by opening to the base URL and clicking through a series of
987 * links.
988 * <p/>
989 * Note: Selenium 1.0-beta-2 has introduced a method start(String) which is distinct from this
990 * implementation (which dates back to Tapestry 5.0 and Selenium 1.0-beta-1).
991 */
992 protected final void start(String... linkText)
993 {
994 open(BASE_URL);
995
996 for (String s : linkText)
997 clickAndWait(String.format("link=%s", s));
998 }
999
1000 public String getWebappRoot()
1001 {
1002 return webappRoot;
1003 }
1004
1005 public void setWebappRoot(String webappRoot)
1006 {
1007 this.webappRoot = webappRoot;
1008 }
1009
1010 /**
1011 * @since 5.1.0.0
1012 */
1013 public void setExtensionJs(String extensionJs)
1014 {
1015 selenium.setExtensionJs(extensionJs);
1016 }
1017
1018 /**
1019 * @since 5.1.0.0
1020 */
1021 public void start(Object optionsObject)
1022 {
1023 selenium.start(optionsObject);
1024 }
1025
1026 /**
1027 * @since 5.1.0.0
1028 */
1029 public void showContextualBanner()
1030 {
1031 selenium.showContextualBanner();
1032 }
1033
1034 /**
1035 * @since 5.1.0.0
1036 */
1037 public void showContextualBanner(String className, String methodName)
1038 {
1039 selenium.showContextualBanner(className, methodName);
1040 }
1041
1042 /**
1043 * @since 5.1.0.0
1044 */
1045 public void mouseDownRight(String locator)
1046 {
1047 selenium.mouseDownRight(locator);
1048 }
1049
1050 /**
1051 * @since 5.1.0.0
1052 */
1053 public void mouseDownRightAt(String locator, String coordString)
1054 {
1055 selenium.mouseDownRightAt(locator, coordString);
1056 }
1057
1058 /**
1059 * @since 5.1.0.0
1060 */
1061 public void captureEntirePageScreenshot(String filename, String kwargs)
1062 {
1063 selenium.captureEntirePageScreenshot(filename, kwargs);
1064 }
1065
1066 /**
1067 * @since 5.1.0.0
1068 */
1069 public void rollup(String rollupName, String kwargs)
1070 {
1071 selenium.rollup(rollupName, kwargs);
1072 }
1073
1074 /**
1075 * @since 5.1.0.0
1076 */
1077 public void addScript(String scriptContent, String scriptTagId)
1078 {
1079 selenium.addScript(scriptContent, scriptTagId);
1080 }
1081
1082 /**
1083 * @since 5.1.0.0
1084 */
1085 public void removeScript(String scriptTagId)
1086 {
1087 selenium.removeScript(scriptTagId);
1088 }
1089
1090 /**
1091 * @since 5.1.0.0
1092 */
1093 public void useXpathLibrary(String libraryName)
1094 {
1095 selenium.useXpathLibrary(libraryName);
1096 }
1097
1098 /**
1099 * @since 5.1.0.0
1100 */
1101 public String captureScreenshotToString()
1102 {
1103 return selenium.captureScreenshotToString();
1104 }
1105
1106 /**
1107 * @since 5.1.0.0
1108 */
1109 public String captureEntirePageScreenshotToString(String kwargs)
1110 {
1111 return selenium.captureEntirePageScreenshotToString(kwargs);
1112 }
1113
1114 /**
1115 * @since 5.1.0.0
1116 */
1117 public String retrieveLastRemoteControlLogs()
1118 {
1119 return selenium.retrieveLastRemoteControlLogs();
1120 }
1121
1122 /**
1123 * @since 5.1.0.0
1124 */
1125 public void mouseUpRight(String locator)
1126 {
1127 selenium.mouseUpRight(locator);
1128 }
1129
1130 /**
1131 * @since 5.1.0.0
1132 */
1133 public void mouseUpRightAt(String locator, String coordString)
1134 {
1135 selenium.mouseUpRightAt(locator, coordString);
1136 }
1137
1138 /**
1139 * This does NOT invoke {@link com.thoughtworks.selenium.Selenium#start(String)}; it invokes
1140 * {@link #start(String[])}. This is necesasry due to the introduction of the start() method.
1141 *
1142 * @param linkText
1143 * text of link to click
1144 * @since 5.1.0.0
1145 */
1146 public void start(String linkText)
1147 {
1148 start(new String[]
1149 { linkText });
1150 }
1151
1152 /**
1153 * @since 5.2.0.0
1154 */
1155 public void addCustomRequestHeader(String key, String value)
1156 {
1157 selenium.addCustomRequestHeader(key, value);
1158 }
1159
1160 /**
1161 * @since 5.2.0.0
1162 */
1163 public String captureNetworkTraffic(String type)
1164 {
1165 return selenium.captureNetworkTraffic(type);
1166 }
1167
1168 /**
1169 * @since 5.2.0.0
1170 */
1171 public void deselectPopUp()
1172 {
1173 selenium.deselectPopUp();
1174 }
1175
1176 /**
1177 * @since 5.2.0.0
1178 */
1179 public void selectPopUp(String windowID)
1180 {
1181 selenium.selectPopUp(windowID);
1182 }
1183
1184 /**
1185 * @since 5.2.0.0
1186 */
1187 public String getLog()
1188 {
1189 return selenium.getLog();
1190 }
1191
1192 /**
1193 * @since 5.2.0.0
1194 */
1195 public void open(String url, String ignoreResponseCode)
1196 {
1197 selenium.open(url, ignoreResponseCode);
1198 }
1199
1200 public Number getCssCount(String str) {
1201 return selenium.getCssCount(str);
1202 }
1203 }