Thursday, January 29, 2015

Selenium WebDriver with C# - Create Helper Classes (2)

Introduction
In this article we will continue transcribing the java code into c# for the following links:
The following are used:
- C# ans language
- Visual Studio 2012 as IDE
- Nunit for tests
- Hudson for continuous integration

ControlUtils

In this chapter we will write functions for working with controls and also how to use them.

Wait Elements

Before starting we need a way to wait an element on the page until it will be displayed. We may either use an implicit wait, by waiting a number of seconds or either waiting the element until is displayed on the page.

- implicit wait
- explicit wait

Functions for Controls
- get_text

- verify text
This function will return true or false and will check if the control's text is correct. You can use it like this.


- element_present
This function will return true or false and will check if the control is present or not on the page. You can use it like this.
- link_present
- click_link
- click_element

Usage: 

- double_click_element

Usage: 


- get_attribute
Below usage will return the Login button class name: 

- is_attribute_present
This will check if an attribute of a control is present or not. Imagine for example that you have to test if a control is or not disabled. Usage:

- send_keys

- refresh_page
- functions for selection controls

Happy testing and make it green becomes a dream!

No comments:

Post a Comment

Popular Posts