Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 3480f6c

Browse files
committed
随机选择后,返回所选择的元素对象
1 parent 2048f14 commit 3480f6c

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/main/java/org/suren/autotest/web/framework/core/action/RandomSelectAble.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public interface RandomSelectAble
2828
/**
2929
* 随机选择
3030
* @param ele
31-
* @return 操作成功返回true,否则返回false
31+
* @return 选中的元素对象
3232
*/
33-
boolean randomSelect(Element ele);
33+
Object randomSelect(Element ele);
3434
}

src/main/java/org/suren/autotest/web/framework/core/ui/Selector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @author suren
3030
* @since jdk1.6
31-
* @since 3.1.1-SNAPSHOT 2016年7月1日
31+
* @since 2016年7月1日
3232
*/
3333
@Component
3434
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@@ -97,9 +97,9 @@ public boolean selectByValue(String value)
9797

9898
/**
9999
* 随机选择一个选项
100-
* @return
100+
* @return 选中的元素对象
101101
*/
102-
public boolean randomSelect()
102+
public Object randomSelect()
103103
{
104104
return randomSelectAble.randomSelect(this);
105105
}

src/main/java/org/suren/autotest/web/framework/selenium/action/SeleniumSelect.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public boolean isMultiple(Element element)
165165
}
166166

167167
@Override
168-
public boolean randomSelect(Element ele)
168+
public WebElement randomSelect(Element ele)
169169
{
170170
Select select = createSelect(ele);
171171
if(select != null)
@@ -178,10 +178,12 @@ public boolean randomSelect(Element ele)
178178
index = (index == 0 ? 1 : index); //通常第一个选项都是无效的选项
179179

180180
select.selectByIndex(index);
181+
182+
return options.get(index);
181183
}
182184
}
183185

184-
return false;
186+
return null;
185187
}
186188

187189
@Override

0 commit comments

Comments
 (0)