-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathResourceLocatorExamples.java
More file actions
63 lines (47 loc) · 1.99 KB
/
ResourceLocatorExamples.java
File metadata and controls
63 lines (47 loc) · 1.99 KB
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
package example;
import com.bottlerocket.webdriverwrapper.uiElementLocator.LocatorStrategy;
import org.openqa.selenium.By;
import org.testng.annotations.Test;
import testmain.TestMain;
import java.net.MalformedURLException;
import java.net.URL;
import static config.ResourceLocator.*;
import static example.config.ResourceLocator.GOOGLE_HOME_INPUT_TEXT_BOX_GOOGLE_SEARCH;
public class ResourceLocatorExamples extends TestMain {
/*
QUICK UI Test to display ResourceLocator usage
URL_GOOGLE: standard String stored in ResourceLocator
INPUT_TEXT_BOX_GOOGLE_SEARCH: By from ResourceLocatorBundle
INPUT_BUTTON_GOOGLE_SEARCH: By from UIElementLocator
*/
@Test()
public void resourceLocatorExamples() throws MalformedURLException {
URL url = new URL(URL_GOOGLE);
setupNextTest(url);
/*
* Retrieving locators using ResourceBundle.
*/
//Option 1: Use it directly
am.driverWrapper.getElement(GOOGLE_HOME_INPUT_TEXT_BOX_GOOGLE_SEARCH.getBy(), 5).sendKeys("what do people google?");
setupNextTest(url);
//Option 2: Store in a By
By input_google_search = GOOGLE_HOME_INPUT_TEXT_BOX_GOOGLE_SEARCH.getBy();
am.driverWrapper.getElement(input_google_search, 5).sendKeys("what do people google?");
setupNextTest(url);
am.driverWrapper.getElement(TEST_BUNDLE_STRING.getBy()).click();
/*
* Retrieving locators using UIElementLocator.
*/
//Option 1
By input_button_google_search = INPUT_BUTTON_GOOGLE_SEARCH.getLocator(LocatorStrategy.XPATH);
am.driverWrapper.getElement(input_button_google_search, 5).click();
setupNextTest(url);
//Option 2
By input_button_google_search_1 = INPUT_BUTTON_GOOGLE_SEARCH.getLocator("button");
am.driverWrapper.getElement(input_button_google_search_1, 5).click();
setupNextTest(url);
}
private void setupNextTest(URL url) {
am.driverWrapper.navigateTo(url);
}
}