Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Selenium Design Patterns and Best Practices

You're reading from   Selenium Design Patterns and Best Practices Build a powerful, stable, and automated test suite using Selenium WebDriver

Arrow left icon
Product type Paperback
Published in Sep 2014
Publisher
ISBN-13 9781783982707
Length 270 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Dima Kovalenko Dima Kovalenko
Author Profile Icon Dima Kovalenko
Dima Kovalenko
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Writing the First Test FREE CHAPTER 2. The Spaghetti Pattern 3. Refactoring Tests 4. Data-driven Testing 5. Stabilizing the Tests 6. Testing the Behavior 7. The Page Objects Pattern 8. Growing the Test Suite A. Getting Started with Selenium Index

Comparing Selenium commands in multiple languages

Translating recorded tests from IDE into Ruby is rather simple, and we can get started even if we do not have any previous programming experience; learning as we go works just fine. The most exciting part is that these commands are even easier to translate from Ruby to any other programming language. Here are a couple of examples of the usage of the sendKeys() method that we used in the preceding example:

Language

Command

Ruby

element.send_keys("cheese");

Java

element.sendKeys("cheese");

C-Sharp

element.SendKeys("cheese");

Python

element.send_keys("cheese");

JavaScript

element.sendKeys("cheese");

The consistency of the WebDriver API makes it incredibly easy to port your knowledge of the test from one language to another. This is great news for you, the test engineer, because you become more valuable to your company. You can be dropped in on any web project, written in any programming language, and start writing tests right away! Information and examples of different WebDriver commands in any programming language can be found at http://docs.seleniumhq.org/docs/.

The preceding example is slightly oversimplified. The action commands are written in the same format from programming language to programming language. However, writing code in different kinds of languages, such as compiled VS interpreted, will have their own idioms and best practices. Some actions that work well in Ruby would be wasteful and counterintuitive in Java.

You have been reading a chapter from
Selenium Design Patterns and Best Practices
Published in: Sep 2014
Publisher:
ISBN-13: 9781783982707
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image