Elements Snippets

Learn to generate Bellatrix web element properties using VS snippets.

Introduction

Instead of copy pasting the elements and modifying them by hand, you can use Bellatrix code snippets to do it lots faster.

What is a Code Snippet?

Code snippets are small blocks of reusable code that can be inserted in a code file using a context menu command or a combination of hotkeys. They typically contain commonly-used code blocks such as try-finally or if-else blocks, but they can be used to insert entire classes or methods. In Visual Studio there are two kinds of code snippet: expansion snippets, which are added at a specified insertion point and may replace a snippet shortcut, and surround-with snippets, which are added to a selected block of code. Bellatrix gives you expansion snippets. You can read more how you can write your snippets in the following blog post.

How to Use Bellatrix Code Snippets?

public TextField CouponCode => Element.CreateById<TextField>("coupon_code");

For each proxy element in Bellatrix, we give you a corresponding snippet. For example to generate a TextField property, you need to type somewhere in you class wtextfield and press Tab. (w comes from web since you have snippets for other Bellatrix modules- desktop and mobile) On the first press of tab, the below code is generated. The first placeholder that is selected is the name of the property. Once you change it, you can press Tab. Then, the second placeholder is chosen- the By locator’s type, by default, it is set to Id, press again Tab and change the actual locator.

Note: Snippets are available for Visual Studio installations only on Windows. You need to make sure you have used the Bellatrix installer to get them.

List of All Available Snippets

Here is the list of all available snippets for Bellatrix Web module:

Snippet Generated Element
wanchor Anchor
wbutton Button
wcheckbox CheckBox
wcolor Color
wdate Date
wdatetimelocal DateTimeLocal
wdiv Div
welement Element
wemail Email
wheading Heading
wimage Image
winputfile InputFile
wlabel Label
wmonth Month
wnumber Number
woption Option
woutput Output
wpassword Password
wphone Phone
wprogress Progress
wradiobutton RadioButton
wrange Range
wreset Reset
wsearch Search
wselect Select
wspan Span
wtextarea TextArea
wtextfield TextField
wtime Time
wurl Url
wweek Week