1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.test.ui.po

File Select.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

2
10
5
1
83
37
6
0.6
2
5
1.2

Classes

Class Line # Actions
Select 32 10 0% 6 7
0.588235358.8%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.test.ui.po;
21   
22    import org.openqa.selenium.Keys;
23    import org.openqa.selenium.WebElement;
24    import org.openqa.selenium.support.ui.UnexpectedTagNameException;
25   
26    /**
27    * Extends {@link org.openqa.selenium.support.ui.Select} in order to fix some bugs.
28    *
29    * @version $Id: bd423a53047eeeb7cf044ce6a4ea007894a16614 $
30    * @since 6.0M1
31    */
 
32    public class Select extends org.openqa.selenium.support.ui.Select
33    {
34    /**
35    * The wrapped select element.
36    */
37    private final WebElement element;
38   
39    /**
40    * Constructor. A check is made that the given element is, indeed, a SELECT tag. If it is not, then an
41    * UnexpectedTagNameException is thrown.
42    *
43    * @param element SELECT element to wrap
44    * @throws UnexpectedTagNameException when element is not a SELECT
45    */
 
46  1 toggle public Select(WebElement element)
47    {
48  1 super(element);
49  1 this.element = element;
50    }
51   
 
52  0 toggle @Override
53    public void selectByIndex(int index)
54    {
55  0 super.selectByIndex(index);
56  0 maybeCloseDropDownList();
57    }
58   
 
59  1 toggle @Override
60    public void selectByValue(String value)
61    {
62  1 super.selectByValue(value);
63  1 maybeCloseDropDownList();
64    }
65   
 
66  0 toggle @Override
67    public void selectByVisibleText(String text)
68    {
69  0 super.selectByVisibleText(text);
70  0 maybeCloseDropDownList();
71    }
72   
73    /**
74    * Sometimes the select drop down list remains opened after we select an option. This is a utility method to close
75    * the drop down list.
76    */
 
77  1 toggle private void maybeCloseDropDownList()
78    {
79  1 if (!isMultiple()) {
80  1 element.sendKeys(Keys.ESCAPE);
81    }
82    }
83    }