Anda di halaman 1dari 15

Selenium Commands

Selenium commands, often called selenese, are the set of commands that run your tests. A sequence of these commands is a test script. Here we explain those commands in detail, and we present the many choices you have in testing your web application when using Selenium.

Verifying Page Elements


Verifying U elements on a web page is probably the most common feature of your automated tests. Selenese allows multiple ways of chec!ing for U elements. t is important that you understand these different methods because these methods define what you are actually testing. "or example, will you test that... #. an element is present somewhere on the page$ %. specific text is somewhere on the page$ &. specific text is at a specific location on the page$ "or example, if you are testing a text heading, the text and its position at the top of the page are probably relevant for your test. f, however, you are testing for the existence of an image on the home page, and the web designers frequently change the specific image file along with its position on the page, then you only want to test that an image 'as opposed to the specific image file( exists somewhere on the page.

Assertion or Verification?
)hoosing between *assert+ and *verify+ comes down to convenience and management of failures. ,here-s very little point chec!ing that the first paragraph on the page is the correct one if your test has already failed when chec!ing that the browser is displaying the expected page. f you-re not on the correct page, you-ll probably want to abort your test case so that you can investigate the cause and fix the issue's( promptly. .n the other hand, you may want to chec! many attributes of a page without aborting the test case on the first failure as this will allow you to review all failures on the page and ta!e the appropriate action. /ffectively an *assert+ will fail the test and abort the current test case, whereas a *verify+ will fail the test and continue to run the test case. ,he best use of this feature is to logically group your test commands, and start each group with an *assert+ followed by one or more *verify+ test commands. An example follows0 Command open Target 1download1 Value

Command

Target

Value 2ownloads Selenium 2/ 3une &, %445 #.4 beta %

assert,itle 2ownloads verify,ext 11h% assert,able #.%.# verify,able #.%.% verify,able #.%.&

,he above example first opens a page and then *asserts+ that the correct page is loaded by comparing the title with the expected value. .nly if this passes will the following command run and *verify+ that the text is present in the expected location. ,he test case then *asserts+ the first column in the second row of the first table contains the expected value, and only if this passed will the remaining cells in that row be *verified+.

verifyTextPresent
,he command verifyTextPresent is used to verify specific text exists somewhere on the page. t ta!es a single argument6the text pattern to be verified. "or example0 Command Target Value

verify,ext7resent 8ar!eting Analysis ,his would cause Selenium to search for, and verify, that the text string *8ar!eting Analysis+ appears somewhere on the page currently being tested. Use verifyTextPresent when you are interested in only the text itself being present on the page. 2o not use this when you also need to test where the text occurs on the page.

verifyElementPresent
Use this command when you must test for the presence of a specific U element, rather then its content. ,his verification does not chec! the text, only the H,89 tag. .ne common use is to chec! for the presence of an image. Command Target Value

verify/lement7resent 11div1p1img ,his command verifies that an image, specified by the existence of an :img; H,89 tag, is present on the page, and that it follows a :div; tag and a :p; tag. ,he first 'and only( parameter is a locator for telling the Selenese command how to find the element. 9ocators are explained in the next section.

can be used to chec! the existence of any H,89 tag within the page. <ou can chec! the existence of lin!s, paragraphs, divisions :div;, etc. Here are a few more examples.
verifyElementPresent

Command verify/lement7resent 11div1p verify/lement7resent 11div1a verify/lement7resent id=9ogin

Target

Value

verify/lement7resent lin!=>o to 8ar!eting ?esearch verify/lement7resent 11a@%A verify/lement7resent 11head1title ,hese examples illustrate the variety of ways a U element may be tested. Again, locators are explained in the next section.

verifyText
Use verifyText when both the text and its U element must be tested. verifyText must use a locator. f you choose an XPath or DOM locator, you can verify that specific text appears at a specific location on the page relative to other U components on the page. Command Target Value ,his is my text and it occurs right after the div inside the table.

verify,ext 11table1tr1td1div1p

Locating Elements
"or many Selenium commands, a target is required. ,his target identifies an element in the content of the web application, and consists of the location strategy followed by the location in the format locatorType=location. ,he locator type can be omitted in many cases. ,he various locator types are explained below with examples for each.

Default Locators
<ou can choose to omit the locator type in the following situations0

9ocators starting with *document+ will use the 2.8 locator strategy. See 9ocating by 2.8 9ocators starting with *11+ will use the B7ath locator strategy. See 9ocating by B7ath. 9ocators that start with anything other than the above or a valid locator type will default to using the identifier locator strategy. See 9ocating by dentifier.

Locating by dentifier
,his is probably the most common method of locating elements and is the catchCall default when no recognised locator type is used. Dith this strategy, the first element with the id attribute value matching the location will be used. f no element has a matching id attribute, then the first element with a name attribute matching the location will be used. "or instance, your page source could have id and name attributes as follows0
1 2 3 4 5 6 7 8 9 <html !<"o#y !!<form!i#=$lo%in&orm$ !!!<inp't!name=$'sername$!type=$text$!( !!!<inp't!name=$pass)or#$!type=$pass)or#$!( !!!<inp't!name=$contin'e$!type=$s'"mit$!val'e=$*o%in$!( !!<(form !<("o#y <html

,he following locator strategies would return the elements from the H,89 snippet above indicated by line number0
i#entifier=lo%in&orm '&( i#entifier='sername 'E( i#entifier=contin'e 'F( contin'e 'F(

Since the i#entifier type of locator is the default, the i#entifier= in the first three examples above is not necessary.

Locating by d
,his type of locator is more limited than the identifier locator type, but also more explicit. Use this when you !now an element-s id attribute.
!1 !2 !3 !4 !5 !6 !7 !8 !9 1+ !<html !!<"o#y !!!<form!i#=$lo%in&orm$ !!!!<inp't!name=$'sername$!type=$text$!( !!!!<inp't!name=$pass)or#$!type=$pass)or#$!( !!!!<inp't!name=$contin'e$!type=$s'"mit$!val'e=$*o%in$!( !!!!<inp't!name=$contin'e$!type=$"'tton$!val'e=$,lear$!( !!!<(form !!<("o#y !<html i#=lo%in&orm '&(

Locating by !ame

,he name locator type will locate the first element with a matching name attribute. f multiple elements have the same value for a name attribute, then you can use filters to further refine your location strategy. ,he default filter type is value 'matching the value attribute(.
!1 !2 !3 !4 !5 !6 !7 !8 !9 1+ !<html !!<"o#y !!!<form!i#=$lo%in&orm$ !!!!<inp't!name=$'sername$!type=$text$!( !!!!<inp't!name=$pass)or#$!type=$pass)or#$!( !!!!<inp't!name=$contin'e$!type=$s'"mit$!val'e=$*o%in$!( !!!!<inp't!name=$contin'e$!type=$"'tton$!val'e=$,lear$!( !!!<(form !<("o#y !<html name='sername 'E( name=contin'e!val'e=,lear 'G( name=contin'e!,lear 'G( name=contin'e!type="'tton 'G(

Hote Unli!e some types of B7ath and 2.8 locators, the three types of locators above allow Selenium to test a U element independent of its location on the page. So if the page structure and organiIation is altered, the test will still pass. <ou may or may not want to also test whether the page structure changes. n the case where web designers frequently alter the page, but its functionality must be regression tested, testing via id and name attributes, or really via any H,89 property, becomes very important.

Locating by "Pat#
B7ath is the language used for locating nodes in an B89 document. As H,89 can be an implementation of B89 'BH,89(, Selenium users can leverage this powerful language to target elements in their web applications. B7ath extends beyond 'as well as supporting( the simple methods of locating by id or name attributes, and opens up all sorts of new possibilities such as locating the third chec!box on the page. .ne of the main reasons for using B7ath is when you don-t have a suitable id or name attribute for the element you wish to locate. <ou can use B7ath to either locate the element in absolute terms 'not advised(, or relative to an element that does have an id or name attribute. B7ath locators can also be used to specify elements via attributes other than id and name. Absolute B7aths contain the location of all elements from the root 'html( and as a result are li!ely to fail with only the slightest adJustment to the application. Ky finding a nearby element with an id or name attribute 'ideally a parent element( you can locate your target element based on the relationship. ,his is much less li!ely to change and can ma!e your tests more robust.

Since only xpath locators start with *11+, it is not necessary to include the xpath= label when specifying an B7ath locator.
!1 !2 !3 !4 !5 !6 !7 !8 !9 1+ !<html !!<"o#y !!!<form!i#=$lo%in&orm$ !!!!<inp't!name=$'sername$!type=$text$!( !!!!<inp't!name=$pass)or#$!type=$pass)or#$!( !!!!<inp't!name=$contin'e$!type=$s'"mit$!val'e=$*o%in$!( !!!!<inp't!name=$contin'e$!type=$"'tton$!val'e=$,lear$!( !!!<(form !<("o#y !<html xpath=(html("o#y(form-1. '&( C Absolute path (would break if the HTM

was changed onl! slightl!" ((form-1. '&( C #irst form element in the HTM xpath=((form-/i#=0lo%in&orm0. '&( C The form element with attribute named $id% and the &alue $login#orm% xpath=((form-inp't(1/name=0'sername0. 'E( C #irst form element with an input child element with attribute named $name% and the &alue $username% ((inp't-/name=0'sername0. 'E( C #irst input element with attribute named $name% and the &alue $username% ((form-/i#=0lo%in&orm0.(inp't-1. 'E( C #irst input child element of the form element with attribute named $id% and the &alue $login#orm% ((inp't-/name=0contin'e0.-/type=0"'tton0. 'G( C 'nput with attribute named $name% and the &alue $continue% and attribute named $t!pe% and the &alue $button% ((form-/i#=0lo%in&orm0.(inp't-4. 'G( C #ourth input child element of the form element with attribute named $id% and &alue $login#orm%

,hese examples cover some basics, but in order to learn more, the following references are recommended0

D&Schools B7ath ,utorial D&) B7ath ?ecommendation B7ath ,utorial C with interactive examples.

,here are also a couple of very useful "irefox AddCons that can assist in discovering the B7ath of an element0

B7ath )hec!er C suggests B7ath and can be used to test B7ath results. "irebug C B7ath suggestions are Just one of the many powerful features of this very useful addCon.

Locating $y%erlin&s by Lin& Text


,his is a simple method of locating a hyperlin! in your web page by using the text of the lin!. f two lin!s with the same text are present, then the first match will be used.

1 2 3 4 5 6 7

<html !<"o#y !!<p 2re!yo'!s're!yo'!)ant!to!#o!this3<(p !!<a!href=$contin'e4html$ ,ontin'e<(a !!<a!href=$cancel4html$ ,ancel<(a <("o#y <html lin5=,ontin'e 'E( lin5=,ancel 'F(

Locating by D'(
,he 2ocument .bJect 8odel represents an H,89 document and can be accessed using 3avaScript. ,his location strategy ta!es 3avaScript that evaluates to an element on the page, which can be simply the element-s location using the hierarchical dotted notation. Since only #om locators start with *document+, it is not necessary to include the #om= label when specifying a 2.8 locator.
!1 !2 !3 !4 !5 !6 !7 !8 !9 1+ !<html !!<"o#y !!!<form!i#=$lo%in&orm$ !!!!<inp't!name=$'sername$!type=$text$!( !!!!<inp't!name=$pass)or#$!type=$pass)or#$!( !!!!<inp't!name=$contin'e$!type=$s'"mit$!val'e=$*o%in$!( !!!!<inp't!name=$contin'e$!type=$"'tton$!val'e=$,lear$!( !!!<(form !<("o#y !<html #om=#oc'ment4%etElement6y7#80lo%in&orm09 '&( #om=#oc'ment4forms-0lo%in&orm0. '&( #om=#oc'ment4forms-+. '&( #oc'ment4forms-+.4'sername 'E( #oc'ment4forms-+.4elements-0'sername0. 'E( #oc'ment4forms-+.4elements-+. 'E( #oc'ment4forms-+.4elements-3. 'G(

<ou can use Selenium itself as well as other sites and extensions to explore the 2.8 of your web application. A good reference exists on D&Schools.

Locating by CSS
)SS ')ascading Style Sheets( is a language for describing the rendering of H,89 and B89 documents. )SS uses Selectors for binding style properties to elements in the document. ,hese Selectors can be used by Selenium as another locating strategy.
!1 !<html !2 !!<"o#y !3 !!!<form!i#=$lo%in&orm$

!4 !5 !6 !7 !8 !9 1+

!!!!<inp't!class=$re:'ire#$!name=$'sername$!type=$text$!( !!!!<inp't!class=$re:'ire#!passfiel#$!name=$pass)or#$!type=$pass)or#$! ( !!!!<inp't!name=$contin'e$!type=$s'"mit$!val'e=$*o%in$!( !!!!<inp't!name=$contin'e$!type=$"'tton$!val'e=$,lear$!( !!!<(form !<("o#y !<html css=form;lo%in&orm!839 css=inp't-name=$'sername$. 'E( css=inp't4re:'ire#-type=$text$. 'E( css=inp't4passfiel#!859 css=;lo%in&orm!inp't-type=$"'tton$. 'E( css=;lo%in&orm!inp't<nth=chil#829 'F(

"or more information about )SS Selectors, the best place to go is the D&) publication. <ou-ll find additional references there. Hote 8ost experienced Selenium users recommend )SS as their locating strategy of choice as it-s considerably faster than B7ath and can find the most complicated obJects in an intrinsic H,89 document.

(atc#ing Text Patterns


9i!e locators, patterns are a type of parameter frequently required by Selenese commands. /xamples of commands which require patterns are verifyTextPresent, verifyTitle, verifyAlert, assertConfirmation, verifyText, and verifyProm%t. And as has been mentioned above, lin! locators can utiliIe a pattern. 7atterns allow you to describe, via the use of special characters, what text is expected rather than having to specify that text exactly. ,here are three types of patterns0 globbing, regular expressions, and exact.

)lobbing Patterns
8ost people are familiar with globbing as it is utiliIed in filename expansion at a 2.S or Unix19inux command line such as ls!>4c. n this case, globbing is used to display all the files ending with a 4c extension that exist in the current directory. >lobbing is fairly limited. .nly two special characters are supported in the Selenium implementation0 * which translates to *match anything,+ i.e., nothing, a single character, or many characters. + , 'character class( which translates to *match any single character found inside the square brac!ets.+ A dash 'hyphen( can be used as a shorthand to specify a range of

characters 'which are contiguous in the AS) character set(. A few examples will ma!e the functionality of a character class clear0
-aeio'. -+=9.

matches any lowercase vowel

matches any digit matches any alphanumeric character

-a=?2=@+=9.

n most other contexts, globbing includes a third special character, the ?. However, Selenium globbing patterns only support the asteris! and character class. ,o specify a globbing pattern parameter for a Selenese command, you can prefix the pattern with a glob- label. However, because globbing patterns are the default, you can also omit the label and specify Just the pattern itself. Kelow is an example of two commands that use globbing patterns. ,he actual lin! text on the page being tested was *"ilm1,elevision 2epartment+L by using a pattern rather than the exact text, the clic& command will wor! even if the lin! text is changed to *"ilm M ,elevision 2epartment+ or *"ilm and ,elevision 2epartment+. ,he glob pattern-s asteris! will match *anything or nothing+ between the word *"ilm+ and the word *,elevision+. Command clic! Target lin!=glob0"ilmN,elevision 2epartment Value

verify,itle glob0N"ilmN,elevisionN ,he actual title of the page reached by clic!ing on the lin! was *2e AnIa "ilm And ,elevision 2epartment C 8enu+. Ky using a pattern rather than the exact text, the verifyTitle will pass as long as the two words *"ilm+ and *,elevision+ appear 'in that order( anywhere in the page-s title. "or example, if the page-s owner should shorten the title to Just *"ilm M ,elevision 2epartment,+ the test would still pass. Using a pattern for both a lin! and a simple test that the lin! wor!ed 'such as the verifyTitle above does( can greatly reduce the maintenance for such test cases.

.egular Ex%ression Patterns


(egular expression patterns are the most powerful of the three types of patterns that Selenese supports. ?egular expressions are also supported by most highClevel programming languages, many text editors, and a host of tools, including the 9inux1Unix commandCline utilities gre%, sed, and a/&. n Selenese, regular expression patterns allow a user to perform many tas!s that would be very difficult otherwise. "or example, suppose your test needed to ensure that a particular table cell contained nothing but a number. re%exp<!-+=9.A is a simple pattern that will match a decimal number of any length.

Dhereas Selenese globbing patterns support only the * and + , 'character class( features, Selenese regular expression patterns offer the same wide array of special characters that exist in 3avaScript. Kelow are a subset of those special characters0 PATTE.! . @A N O $ P#,FQ R '( any single character character class0 any single character that appears inside the brac!ets quantifier0 4 or more of the preceding character 'or group( quantifier0 # or more of the preceding character 'or group( quantifier0 4 or # of the preceding character 'or group( quantifier0 # through F of the preceding character 'or group( alternation0 the character1group on the left or the character1group on the right grouping0 often used with alternation and1or quantifier (ATC$

?egular expression patterns in Selenese need to be prefixed with either re%exp< or re%expi<. ,he former is caseCsensitiveL the latter is caseCinsensitive. A few examples will help clarify how regular expression patterns can be used with Selenese commands. ,he first one uses what is probably the most commonly used regular expression pattern60* '*dot star+(. ,his twoCcharacter sequence can be translated as *4 or more occurrences of any character+ or more simply, *anything or nothing.+ t is the equivalent of the oneCcharacter globbing pattern * 'a single asteris!(. Command clic! Target lin!=regexp0"ilm.N,elevision 2epartment Value

verify,itle regexp0.N"ilm.N,elevision.N ,he example above is functionally equivalent to the earlier example that used globbing patterns for this same test. ,he only differences are the prefix 'regex%- instead of glob-( and the *anything or nothing+ pattern '0* instead of Just *(. ,he more complex example below tests that the <ahooS Deather page for Anchorage, Alas!a contains info on the sunrise time0 Command open Target http011weather.yahoo.com1forecast1USAT44#%.html Value

verify,ext7resent regexp0Sunrise0 N@4CUAP#,%Q0@4CUAP%Q @apAm 9et-s examine the regular expression above one part at a time0

B'nrise<!> -+=9.C1D2E < -+=9.C2E -ap.m

,he string Sunrise- followed by 4 or more spaces # or % digits 'for the hour of the day( ,he character - 'no special characters involved( % digits 'for the minutes( followed by a space *a+ or *p+ followed by *m+ 'am or pm(

Exact Patterns
,he exact type of Selenium pattern is of marginal usefulness. t uses no special characters at all. So, if you needed to loo! for an actual asteris! character 'which is special for both globbing and regular expression patterns(, the exact pattern would be one way to do that. "or example, if you wanted to select an item labeled *?eal N+ from a dropdown, the following code might wor! or it might not. ,he asteris! in the %lo"<Feal! > pattern will match anything or nothing. So, if there was an earlier select option labeled *?eal Humbers,+ it would be the option selected rather than the *?eal N+ option. select 11select glob0?eal N n order to ensure that the *?eal N+ item would be selected, the exact< prefix could be used to create an exact pattern as shown below0 select 11select exact0?eal N Kut the same effect could be achieved via escaping the asteris! in a regular expression pattern0 select 11select regexp0?eal VN t-s rather unli!ely that most testers will ever need to loo! for an asteris! or a set of square brac!ets with characters inside them 'the character class for globbing patterns(. ,hus, globbing patterns and regular expression patterns are sufficient for the vast maJority of us.

T#e 1And2ait3 Commands


,he difference between a command and its And)ait alternative is that the regular command 'e.g. click( will do the action and continue with the following command as fast as it can, while the And)ait alternative 'e.g. clickAnd)ait( tells Selenium to /ait for the page to load after the action has been done. ,he And)ait alternative is always used when the action causes the browser to navigate to another page or reload the present one.

Ke aware, if you use an And)ait command for an action that does not trigger a navigation1refresh, your test will fail. ,his happens because Selenium will reach the And)aitWs timeout without seeing any navigation or refresh being made, causing Selenium to raise a timeout exception.

T#e /ait4or Commands in A5A" a%%lications


n A3AB driven web applications, data is retrieved from server without refreshing the page. Using and)ait commands will not wor! as the page is not actually refreshed. 7ausing the test execution for a certain period of time is also not a good approach as web element might appear later or earlier than the stipulated period depending on the system-s responsiveness, load or other uncontrolled factors of the moment, leading to test failures. ,he best approach would be to wait for the needed element in a dynamic period and then continue the execution as soon as the element is found. ,his is done using wait#or commands, as wait#or*lementPresent or wait#or+isible, which wait dynamically, chec!ing for the desired condition every second and continuing to the next command in the script as soon as the condition is met.

Se6uence of Evaluation and 4lo/ Control


Dhen a script runs, it simply runs in sequence, one command after another. Selenese, by itself, does not support condition statements 'ifCelse, etc.( or iteration 'for, while, etc.(. 8any useful tests can be conducted without flow control. However, for a functional test of dynamic content, possibly involving multiple pages, programming logic is often needed. Dhen flow control is needed, there are three options0 #. ?un the script using SeleniumC?) and a client library such as 3ava or 7H7 to utiliIe the programming language-s flow control features. %. ?un a small 3avaScript snippet from within the script using the store/val command. &. nstall the gotoXselXide.Js extension. 8ost testers will export the test script into a programming language file that uses the SeleniumC?) A7 'see the SeleniumC 2/ chapter(. However, some organiIations prefer to run their scripts from SeleniumC 2/ whenever possible 'such as when they have many JuniorClevel people running tests for them, or when programming s!ills are lac!ing(. f this is your case, consider a 3avaScript snippet or the gotoXselXide.Js extension.

Store Commands and Selenium Variables

<ou can use Selenium variables to store constants at the beginning of a script. Also, when combined with a dataCdriven test design 'discussed in a later section(, Selenium variables can be used to store values passed to your test program from the commandCline, from another program, or from a file. ,he plain store command is the most basic of the many store commands and can be used to simply store a constant value in a selenium variable. t ta!es two parameters, the text value to be stored and a selenium variable. Use the standard variable naming conventions of only alphanumeric characters when choosing a name for your variable. Command store Target Value

paulYmysite.org userHame

9ater in your script, you-ll want to use the stored value of your variable. ,o access the value of a variable, enclose the variable in curly brac!ets 'PQ( and precede it with a dollar sign li!e this. Command Target Value

verify,ext 11div1p ZPuserHameQ A common use of variables is for storing input for an input field. Command Target type Value

id=login ZPuserHameQ

Selenium variables can be used in either the first or second parameter and are interpreted by Selenium prior to any other operations performed by the command. A Selenium variable may also be used within a locator expression. An equivalent store command exists for each verify and assert command. Here are a couple more commonly used store commands.

storeElementPresent
,his corresponds to verify/lement7resent. t simply stores a boolean value6+true+ or *false+6depending on whether the U element is found.

storeText
Store,ext corresponds to verify,ext. t uses a locater to identify specific page text. ,he text, if found, is stored in the variable. Store,ext can be used to extract text from the page being tested.

storeEval
,his command ta!es a script as its first parameter. /mbedding 3avaScript within Selenese is covered in the next section. Store/val allows the test to store the result of running the script in a variable.

5avaScri%t and Selenese Parameters


3avaScript can be used with two types of Selenese parameters6scri%t and nonCscript 'usually expressions(. n most cases, you-ll want to access and1or manipulate a test case variable inside the 3avaScript snippet used as a Selenese parameter. All variables created in your test case are stored in a 3avaScript associati&e arra!. An associative array has string indexes rather than sequential numeric indexes. ,he associative array containing your test case-s variables is named storedVars. Dhenever you wish to access or manipulate a variable within a 3avaScript snippet, you must refer to it as storedVars+7yourVariable!ame8,.

5avaScri%t 9sage /it# Scri%t Parameters


Several Selenese commands specify a scri%t parameter including assertEval, verifyEval, storeEval, and /ait4orEval. ,hese parameters require no special syntax. A SeleniumC 2/ user would simply place a snippet of 3avaScript code into the appropriate field, normally the Target field 'because a scri%t parameter is normally the first or only parameter(. ,he example below illustrates how a 3avaScript snippet can be used to perform a simple numerical calculation0 Command store store/val #4 storeBpath)ount 11bloc!quote Target Value hits bloc!quotes

storedVars@Whits-ACstoredVars@Wbloc!quotes-A paragraphs

,his next example illustrates how a 3avaScript snippet can include calls to methods, in this case the 3avaScript String obJect-s toGpper,ase method and to*o)er,ase method. Command store store/val store/val Target /dith Dharton Value name

storedVars@Wname-A.toUpper)ase'( uc storedVars@Wname-A.to9ower)ase'( lc

5avaScri%t 9sage /it# !on:Scri%t Parameters

3avaScript can also be used to help generate values for parameters, even when the parameter is not specified to be of type scri%t. However, in this case, special syntax is required6the 3avaScript snippet must be enclosed inside curly braces and preceded by the label Havascript, as in Havascript!C>yo'r,o#eIere>E. Kelow is an example in which the type command-s second parameter val'e is generated via 3avaScript code using this special syntax0 Command store type q Target league of nations searchString JavascriptPstoredVars@WsearchString-A.toUpper)ase'(Q Value

echo : T#e Selenese Print Command


Selenese has a simple command that allows you to print text to your test-s output. ,his is useful for providing informational progress notes in your test which display on the console as your test is running. ,hese notes also can be used to provide context within your test result reports, which can be useful for finding where a defect exists on a page in the event your test finds a problem. "inally, echo statements can be used to print the contents of Selenium variables. Command echo echo Target ,esting page footer now. Username is ZPuserHameQ Value

Anda mungkin juga menyukai