Skip to main content

You are here

c#

List all suggested search terms in Google

The following code opens the browser and navigates to Google. It then types in "Mado" into the search box. A list of search suggestions drop down. The program captures and prints all the suggestions. Allow the progam to finish - you will know when the "WebDriver" printed in the lower right corner of the browser window turns to black. Close the browser window and observe the listed options in the console.

Note: You should have downloaded and set reference to Selenium dot net library from the Selenium HQ website.

Video tutorial on NUnit + c# implementation

I found this excellent video on NUnit implementation on c#. The video takes some time to load but its worth waiting for.
http://ndc2011.macsimum.no/SAL5/Onsdag/1020-1120.wmv

Scroll bars dragging

The following code demonstrates how to drag the vertical scroll bars on a window. The "Actions" class is used to click and hold on to the scroll bar and then it is dragged to a new location.

Switch between two open windows or browser tabs

The following code demonstrates the SwitchTo() function. A popup window is opened from a main window and then control or focus is switched between these windows. This is particularly useful for when a test calls up a second window or popup and testing continues on the newly opened window. This code also demonstrates the use of an "Iterator".

How to simulate mouse movement in Selenium WebDriver

This code navigates to a website www.choice-fm.co.uk. It then simulates moving the mouse from one menu link to the other. Observe the dropdown menu as focus shifts from one menu option to the other. There is a slight delay between each menu option (curtesy of Thread.sleep).

For some strange reason a previously visited menu link's dropdown remained even after focus shifted. Hoping some gurus can explain that to us in the comments sections. smiley

Premium Drupal Themes by Adaptivethemes