Материалы с 31 встречи QA Community Днепропетровск

29 мая состоялась 31 встреча QA Community Днепропетровск. Проходила она в формате практикума по автоматизации тестирования с помощью Selenium WebDriver для начинающих.

Провести эту встречу помогли компания Ciklum и компания PFSoft.

Фото с 31 встречи QA Community Днепропетровск

Мы получили массу положительных отзывов, все замечания и пожелания – будут учтены при следующей встрече.
По итогам проведенного мероприятия, Александр Романов написал
немного информации о создании проекта и запуске того теста, который мы запускали(пытались запустить 🙂 ), ответы на часто задаваемые вопросы, а также на вопросы, которые мы не успели рассмотреть в рамках этой встречи.

{Selenium WebDriver starter guide}: Step 0 – Intro words
So you want to begin with test automation? And you don’t know where to start?
Don’t worry:). In current series of posts you can find all necessary information which you should perform in order to write your first tests using Selenium WebDriver.

Step 0 – Few words about test automation

Before we start diving into the magical world of WebDriver, let me say a few words about automation itself and what you should know, if you want effectively use Selenium or any test automation tool. Don’t forget that the selection of tool depends on task, which you want to perform (and also from a stack of technologies on a project).
The Wikipedia says, that test automation is the use of special software (separate from the software being tested) to control the execution of tests and the comparison of actual outcomes with predicted outcomes.
In a software engineering, ‘special software’ – it is not only a separate tool, which you are using to record-and-play test scenarios. In most cases – it’s a test code, which has been written by test automation engineers / SDET ‘ s in order to test the target software. So you should consider automated tests as a part of your product code. The test code should be written with the same practices, patterns and quality, as a product code. It should be carefully reviewed, refactored if it’s needed. Actually, by writing automated tests, or some test tools – we also create a new ‘product’ – so it should works properly and fulfill all our requirements.
As we consider the test code as a ‘product’ code, we, as test automation engineers, should write this code effectively. We can do it only by one way – we should learn a programming language. Yes, the starting point of any successful test automation engineer is a good level of programming skills. Many successful software companies have almost the same set of interview questions for software developers and for software testers. So programming skills in automation are crucial. That’s why, I recommend you to choose programming language, which you prefer, and learn it and practice. It can be high-level languages, such as Java or C#, or some scripting languages – Python, Ruby, Groovy, etc.
Also I want to admit, that each successful software engineer, should have a passion or curiosity about the industry, technologies, about his work. So if you found something, some word, some practice, pattern, tool, which you don’t know – just Google it! Get to know as much as possible about it, how to use it, and maybe, in future, it will help you to solve some difficult work problem.
Develop yourself and your skills continuously:)! And good luck!

{Selenium WebDriver starter guide}: Step 1 – Preparing an environment

So you want to begin with test automation? And you don’t know where to start?
Don’t worry:). In current series of posts you can find all necessary information which you should perform in order to write your first tests using Selenium WebDriver.

NOTES!
Examples language: Java
Target browsers: Mozilla Firefox, Google Chrome (latest versions).
Platform OS: Windows 7.
All examples in starter guide will be provided in Java, but you can use any language, which WebDriver supports.

Java JDK installation:
Before installation you should check your Windows version (whether it x86 or x64) and download an appropriate jdk version (it’s recommended to use jdk7).
http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html
After installation, do not forget to check that Java has been correctly installed, by running ‘java –version’ command at command line.

Installing an IDE.
What is IDE itself? http://en.wikipedia.org/wiki/Integrated_development_environment
Which IDE is better?
It is only your choice, what IDE to use. You can use any of them (IntelliJ IDEA, Eclipse, Netbeans, etc) to write Webdriver tests.
– IntelliJ IDEA (use free version):
http://www.jetbrains.com/idea/download/
On current website you can also find a quick guide about a common controls in IDEA.
– Eclipse: https://ist.berkeley.edu/as-ag/tools/howto/install-eclipse-win.html
– Netbeans: https://netbeans.org/community/releases/70/install.html

Obtaining Selenium Webdriver
Follow http://docs.seleniumhq.org/download/ link and download Selenium Client & Webdriver Language bindings for Java language.

Unzip downloaded file. It should contain two *.jar files in root and a lot 🙂 of *.jar files in libs folder.

{Selenium WebDriver starter guide}: Step 10 – Creating a project and running first test

So you want to begin with test automation? And you don’t know where to start?
Don’t worry:). In current series of posts you can find all necessary information which you should perform in order to write your first tests using Selenium WebDriver.

Before creating a project please refer to:
http://stackoverflow.com/questions/1953048/java-project-structure-explained-for-newbies

Also please verify if the latest version of Mozilla Firefox browser has been installed on your computer.

Creating a new Java project in chosen IDE:
– IDEA: http://wiki.jetbrains.net/intellij/Setting_up_a_project_in_IntelliJ_IDEA
– Netbeans: http://docs.oracle.com/cd/E50453_01/doc.80/e50452/create_japps.htm#NBDAG366
– Eclipse: http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FgettingStarted%2Fqs-3.htm

Adding Selenium libraries into the project:
What is *jar? http://en.wikipedia.org/wiki/JAR_(file_format)
In order to use Selenium Webdriver, we need to add it’s *jar files into the project.
– IDEA:
http://confluence.jetbrains.com/display/IntelliJIDEA/External+References
– Eclipse:
o Select the library and click “Edit” (left side of the window)
o Click “User Libraries”
o Select the library again and click “Add JARs”
– Netbeans:
http://jsumon.wordpress.com/2009/11/24/adding-external-jar-or-library-to-netbeans-java-project/

Adding TestNG into project:
What is TestNG? http://testng.org/doc/index.html
How we can add it to our java project?
IntelliJ IDEA – http://testng.org/doc/idea.html
Eclipse – http://testng.org/doc/eclipse.html

Creating a new Java class (name it as SimpleTest.java):
IntelliJ IDEA – http://www.jetbrains.com/idea/webhelp/creating-java-classes-interfaces-enumerations-and-annotations.html
Eclipse – http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FgettingStarted%2Fqs-9.htm

Fill your class with the following code:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.assertTrue;

public class SimpleTest {
protected WebDriver driver;

@BeforeClass
public void setUp() {
driver = new FirefoxDriver();
driver.get(“http://qacommunity.com.ua/”);
}

@Test
public void checkQaCommunityTest() {
WebElement logo = driver.findElement(By.xpath(“//a[@href=’http://qacommunity.com.ua/’]”));
assertTrue(logo.isDisplayed(), “Logo QA Community not found!”);
}

@AfterClass
public void tearDown() {
driver.close();
}
}

Save the current file.

Running the test:
IntelliJ IDEA – Ctrl+Shift+F10

Expected result:
– Firefox browser should be started;
– you should be navigated to http://qacommunity.com.ua/ page;
– QA community logo should be displayed on page;
– browser should closed after the test run;