2013年12月11日星期三

a very useful clsss SELECT in webdriver

Actually,the selenium is really powerful for automation testing.when you first use it,maybe you feel it is very simple,but if you are just satisfied with the simple use,you really insult the selenium.here I introduced a very useful class ---select,I first heard the class is in Darrell's blog http://darrellgrainger.blogspot.com/ really recommend all chinesed testers to browse the blog,I really get a lot from the author.
After I get the class,I tried to dig into the orignal code,the class is really powerful,it help us do a lot of things.
first,select class is used to :
Models a SELECT tag, providing helper methods to select and deselect options.

the tag SELECT is really common in our web testing,mostly,when we do not know the class,normally we will use xpath or cssselector to locate the select

but what the class supplies are:
void deselectAll()
Clear all selected entries.
void deselectByIndex(int index)
Deselect the option at the given index.
void deselectByValue(java.lang.String value)
Deselect all options that have a value matching the argument.
void deselectByVisibleText(java.lang.String text)
Deselect all options that display text matching the argument.
protected java.lang.String escapeQuotes(java.lang.String toEscape) 
java.util.List<WebElement> getAllSelectedOptions() 
WebElement getFirstSelectedOption() 
java.util.List<WebElement> getOptions() 
boolean isMultiple() 
void selectByIndex(int index)
Select the option at the given index.
void selectByValue(java.lang.String value)
Select all options that have a value matching the argument.
void selectByVisibleText(java.lang.String text)
Select all options that display text matching the argument.
do all the things for us ,what we need to do is just finding the method,here is a tip:if you wanna know the method more deeply,it is very useful to read the code,you will know what the are doing

没有评论:

发表评论