1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.aludratest.service.gui.web.selenium;
17
18 import org.aludratest.config.ConfigProperties;
19 import org.aludratest.config.ConfigProperty;
20 import org.aludratest.config.Preferences;
21 import org.aludratest.service.AbstractConfigurableAludraService;
22 import org.aludratest.service.ComponentId;
23 import org.aludratest.service.gui.component.GUIComponentFactory;
24 import org.aludratest.service.gui.component.impl.DefaultGUIComponentFactory;
25 import org.aludratest.service.gui.web.AludraWebGUI;
26 import org.codehaus.plexus.component.annotations.Requirement;
27
28
29
30
31 @ConfigProperties({
32 @ConfigProperty(name = "timeout", type = int.class, description="Timeout in milliseconds after which a test step stops retrying doing a action.", defaultValue = "15000"),
33 @ConfigProperty(name = "speed", type = int.class, description="Speed in milliseconds. What means that between each Selenium command Selenium waits x milliseconds where x is the speed.", defaultValue="50"),
34 @ConfigProperty(name = "browser.log.level", type = String.class, description = "The browser log level. One of debug, info, warn, error.", defaultValue = "error"),
35 @ConfigProperty(name = "highlight.elements", type = boolean.class, description = "Activates or deactivates highlighting of web GUI elements currently being used.", defaultValue = "true"),
36 @ConfigProperty(name = "pause.between.retries", type = int.class, description = "If execution of an action fails, Selenium has to pause until it retries to execute this action again. This value specifies how long the program will pause, in milliseconds.", defaultValue = "100"),
37 @ConfigProperty(name = "locator.prefix", type = String.class, description = "This value specifies the default prefix of an ID locator. With the help of this prefix, Selenium can be influenced how it locates elements. Selenium provides several mechanisms for that like regular expressions etc.", defaultValue = "css=[id$=\""),
38 @ConfigProperty(name = "locator.suffix", type = String.class, description = "The matching suffix to the ID locator prefix.", defaultValue = "\"]"),
39 @ConfigProperty(name = "screenshot.attachment.extension", type = String.class, description = "The file extension to use for screenshot attachments.", defaultValue = "png"),
40 @ConfigProperty(name = "page.source.attachment.extension", type = String.class, description = "The file extension to use for HTML page source attachments.", defaultValue = "html"),
41 @ConfigProperty(name = "task.start.timeout", type = int.class, description = "The time the Selenium service waits for an activity to start, in milliseconds.", defaultValue = "2000"),
42 @ConfigProperty(name = "task.completion.timeout", type = int.class, description = "The time the Selenium service waits for an activity to finish, in milliseconds.", defaultValue = "45000"),
43 @ConfigProperty(name = "task.polling.interval", type = int.class, description = "The polling interval for checking task states, in milliseconds.", defaultValue = "1000")
44 })
45 public abstract class AbstractSeleniumService extends AbstractConfigurableAludraService implements AludraWebGUI {
46
47 protected SeleniumWrapperConfiguration configuration;
48
49 @Requirement(hint = "default")
50 private GUIComponentFactory componentFactory;
51
52 private boolean componentFactoryConfigured;
53
54 @Override
55 public final String getPropertiesBaseName() {
56 return "seleniumWrapper";
57 }
58
59 @Override
60 public final void configure(Preferences preferences) {
61 configuration = new SeleniumWrapperConfiguration(preferences);
62 }
63
64 @Override
65 public GUIComponentFactory getComponentFactory() {
66 if (!componentFactoryConfigured) {
67 ComponentId<AludraWebGUI> componentId = ComponentId
68 .create(AludraWebGUI.class, aludraServiceContext.getInstanceName());
69 ((DefaultGUIComponentFactory) componentFactory).configureForGUIService(aludraServiceContext, componentId);
70 componentFactoryConfigured = true;
71 }
72 return componentFactory;
73 }
74
75 }