1
2
3
4 package org.sirius.server.web;
5
6 import java.util.List;
7
8 import javax.jws.WebService;
9
10 import org.openqa.selenium.WebElement;
11 import org.openqa.selenium.support.ui.Select;
12
13
14
15
16
17 @WebService
18 public class WebSelect extends WebHelper {
19
20
21
22
23 public WebSelect() {
24 ;
25 }
26
27 private Select get(String token, String parentLocator, String locator){
28 Select control = new Select( this.getElement(token, parentLocator, locator) );
29 return control;
30 }
31
32 public void deselectAll(String token, String parentLocator, String locator){
33 get(token,parentLocator,locator).deselectAll();
34 }
35
36 public void deselectByIndex(String token, String parentLocator, String locator,int index){
37 get(token,parentLocator,locator).deselectByIndex(index);
38 }
39
40 public void deselectByValue(String token, String parentLocator, String locator,String value){
41 get(token,parentLocator,locator).deselectByValue(value);
42 }
43
44 public void deselectByVisibleText(String token, String parentLocator, String locator, String text){
45 get(token,parentLocator,locator).deselectByVisibleText(text);
46 }
47
48 public String[] getAllOptions(String token, String parentLocator, String locator){
49 List<WebElement> elements = get(token,parentLocator,locator).getOptions();
50 String data[] = new String[elements.size()];
51
52 for(int i=0;i<elements.size();i++){
53 data[i] = elements.get(i).getText();
54 }
55
56 return data;
57 }
58
59 public String[] getAllSelectedOptions(String token, String parentLocator, String locator){
60 List<WebElement> elements = get(token,parentLocator,locator).getAllSelectedOptions();
61 String data[] = new String[elements.size()];
62
63 for(int i=0;i<elements.size();i++){
64 data[i] = elements.get(i).getText();
65 }
66
67 return data;
68 }
69
70 public String getFirstSelectedOption(String token,String parentLocator, String locator){
71 return get(token,parentLocator,locator).getFirstSelectedOption().getText();
72 }
73
74 public boolean isMultiple(String token, String parentLocator, String locator){
75 return get(token,parentLocator,locator).isMultiple();
76 }
77
78 public void selectByIndex(String token, String parentLocator, String locator,int index){
79 get(token,parentLocator,locator).selectByIndex(index);
80 }
81
82 public void selectByValue(String token, String parentLocator, String locator,String value){
83 get(token,parentLocator,locator).selectByValue(value);
84 }
85
86 public void selectByVisibleText(String token, String parentLocator, String locator, String text){
87 get(token,parentLocator,locator).selectByVisibleText(text);
88 }
89 }