Pay attention to following commands as these are going to play pivotal role in selenium.
1: SelectFrame (locator):
To learn this command we need to understand basics of HTML frame element first. Spend some time to learn HTML Frames, if don’t know much about frame elements. While performing any action to any web element, we first select the frame where it resides then we perform any action to any element inside that frame. To access other elements coded in different frame, again we need to select that frame using this command and then we can access their elements. We use frame name as locator. To select the parent frame, use “relative=parent” as a locator; to select the top frame, use “relative=top”. You can also select a frame by its 0-based index number; select the first frame with “index=0”, or the third frame with “index=2”.
2: WaitForCondition (script, timeout):
Selenium.WaitForCondition (“selenium.IsElementPresent (“id=buttonID”)”, 60000);
Explanation: This command will execute repeatedly until selenium.IsElementPresent () returns true or reach timeout period. Even after 60000 ms, if selenium.IsElementPresent () doesn’t find desired element, WaitForConition command returns false.
3: WaitForPageToLoad (timeout):
This is another very important selenium command that people use in testing. We need to wait for page to load either do some action or to verify if there is new page or frame being load on the browser. It works most of time but on some instances it doesn’t which I will explain later. We will create customized method using WaitForCondition command to perform waitForPageToLoad action.
4: fireEvent (locator, eventName):
This command use to explicitly simulate an event, to trigger the corresponding “onevent” handler. There are some of instances where search box perform search process as soon as we start typing in the field but that only possible if type manually. that doesn’t work if we just send selenium.Type() command to the element. In such cases we need to send fireEvent command with eventName like onChange, onFocus etc., depending upon the associated event to the search box. We will talk about this in more detail on upcoming posts.
5: AddLocationStrategy(StrategyName, Strategy):
This command is very powerful command of selenium. We will use to write a strategy to capture the web element or locator smartly. For example, if you define the strategy of name “foo”, we need to use this “foo” with ‘=’ to define locator. To use this strategy effectively we will use with “foo=blah bblah” in our code. In later section I will show you, how to use jQuery for our location strategy and start doing greedy search for every element without any hassle. Here is basic example of that but we will go in more detail in later sections. Suppose you want to click on <button> element with id=”a”, you will write command selenium.Click(“jquery=button[id=’a’]”); where ‘jquery’ is the name of the strategy. Just make sure that you run addLocationStrategy command in very beginning of you code.
There are few more commands like isElementPresent, isTextPresent, Assert, Verify, which is also an important command for testing but I don’t think we need special explanation here. You can refer them from various from or seleniumhq.org. I would recommend you to do more and more practice on these commands so you will be well acquainted.
var _gaq = _gaq || ; _gaq.push(['_setAccount', 'UA-37496715-1']); _gaq.push(['_trackPageview']);