-
Notifications
You must be signed in to change notification settings - Fork 7
/
Screen.java
84 lines (72 loc) · 2.17 KB
/
Screen.java
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
package aquality.appium.mobile.screens;
import aquality.appium.mobile.application.AqualityServices;
import aquality.appium.mobile.elements.interfaces.IElement;
import aquality.appium.mobile.elements.interfaces.IElementFactory;
import aquality.selenium.core.configurations.IVisualizationConfiguration;
import aquality.selenium.core.elements.interfaces.IElementStateProvider;
import aquality.selenium.core.forms.Form;
import aquality.selenium.core.localization.ILocalizedLogger;
import org.openqa.selenium.By;
import java.awt.*;
/**
* Defines base class for any UI form.
*/
public abstract class Screen extends Form<IElement> implements IScreen {
/**
* Locator for specified form
*/
private final By locator;
/**
* Name of specified form
*/
private final String name;
/**
* Screen element defined by its locator and name.
*/
private final IElement screenElement;
/**
* Constructor with parameters
*/
protected Screen(By locator, String name) {
super(IElement.class);
this.locator = locator;
this.name = name;
this.screenElement = getElementFactory().getLabel(locator, name);
}
@Override
public By getLocator() {
return locator;
}
@Override
public String getName() {
return name;
}
@Override
public Dimension getSize() {
return screenElement.visual().getSize();
}
@Override
public IElementStateProvider state() {
return screenElement.state();
}
/**
* Gets form element defined by its locator and name.
* Could be used to find child elements relative to form element.
*
* @return form element.
*/
protected IElement getScreenElement() {
return screenElement;
}
protected IElementFactory getElementFactory(){
return AqualityServices.getElementFactory();
}
@Override
protected IVisualizationConfiguration getVisualizationConfiguration() {
return AqualityServices.getConfiguration().getVisualizationConfiguration();
}
@Override
protected ILocalizedLogger getLocalizedLogger() {
return AqualityServices.getLocalizedLogger();
}
}