Element Locator
Element Locators tell Selenium which HTML element a command refers to. The format of a locator is: locatorType=argument Example: - (“link=click”) Selenium supports the following strategies for locating elements: id=id Select the element with the specified @id attribute name=name Select the first element with the specified @name attribute. · username · name=username xpath=xpathExpression Locate an element using an XPath expression. · xpath=//img[@alt='The image alt text'] · xpath=//table[@id='table1']//tr[4]/td[2] link=textPattern Select the link (anchor) element which contains text matching the specified pattern. · link=The link text
Important Selenium Commands
Command | Usage | Description |
start() | selenium.start(); | Launches the browser with a new Selenium session |
stop() | selenium.stop(); | Ends the current Selenium testing session (normally killing the browser) |
click() | selenium.click("link=Home"); selenium.click("name=send"); | Clicks on a link, button, checkbox or radio button. If the click action causes a new page to load (like a link usually does), call waitForPageToLoad. |
doubleClick() | | Double clicks on a link, button, checkbox or radio button. If the double click action causes a new page to load (like a link usually does), call waitForPageToLoad. |
type() | selenium.type("name=login[username]", ndasam); | Sets the value of an input field, as though you typed it in. Can also be used to set the value of combo boxes, check boxes, etc. In these cases, value should be the value of the option selected, not the visible text. |
check() | selenium.check ("guest”); | Check a toggle-button (checkbox/radio) |
uncheck() | Uncheck a toggle-button (checkbox/radio) | |
select() | selenium.select("payware_expiration_yr", "label=2010”); | Select an option from a drop-down using an option locator. |
| | |
it is good for beginners, if you add more it is very useful.
ReplyDeleteThanks NagaRaju,
ReplyDeleteplease tel me how to use selenium IDE. how to apply conditions using Selenium IDE.
please help me.
Good to know for Selenium Freshers
ReplyDelete