SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
Хороший тест
-
простой тест
Андрей Солнцев
Selenide:
Нафига?
Don’t put logic in tests
@Test
public void shouldNavigateToPhotosPage() {
String baseUrl = "http://plus.google.com/";
Navigator nav = new Navigator(baseUrl);
nav.goToPhotosPage();
assertEquals(baseUrl + "/u/0/photos",
nav.getCurrentUrl());
}
http://googletesting.blogspot.com/2014/07/testing-on-toilet-dont-put-logic-in.html
Don’t put logic in tests
@Test
public void shouldNavigateToPhotosPage() {
Navigator nav = new Navigator("http://plus.google.com/");
nav.goToPhotosPage();
assertEquals("http://plus.google.com//u/0/photos",
nav.getCurrentUrl());
}
Упс!
Код
Общий алгоритм Частные случаи
Тест
C = SQRT(A*A + B*B)
assert hyph(3,4) == 5
assert hyph(5,12) == 13
assert hyph(1,1) == 1.41
assert hyph(0,0) == 0
assert hyph(-1,3) -> error
ТестыКод
сложный простые
копипаст
нельзя
копипаст
можно
Тесты - максимально простые!
● условия
● переменные
● вычисления
● циклы
привносят в тесты ошибки!
А тем более:
● Page Object
● Factory
● Builder
● “карточки”
● и т.д.
Усложнения в тесты
Стоит вносить осознанно
● только по необходимости
● понимая риски
Итак,
чем же хорош Selenide?
Selenide
● позволяет начать очень просто
● и усложнять при необходимости
● при написании
● при отладке
экономит массу времени
- синтаксис + API
- умное ожидание
(20%)
(80%)
Пример: Google search
Google search - Page Object
Selenide
новинки
1. Автоматические скриншоты
На Jenkins - публичный URL:
build.gradle
2. Методы $.hover(), $.dragAndDrop()
3. Поиск родителей
● $.parent()
● $.closest(“table”)
● $.closest(“.modal”)
4. $.uploadFile(File file)
4. $.uploadFile(File … files)
5. sizzle selectors
6. zoom in/out
7. Selenide profiler
Report for userCanReplyToIncomingMessages(ui.BankMessagesSpec)
+----------------------+---------------------------------------------+--------+----------+
|Element |Subject |Status |ms. |
+----------------------+---------------------------------------------+--------+----------+
|open |http://localhost:2070/ |PASSED |4669 |
|open |http://localhost:2070/fakeLogin?username=bob |PASSED |1324 |
|By.linkText: Quicky |click() |PASSED |793 |
|#btn-message-reply |click() |PASSED |1002 |
|By.name: message.text |should be(focused) |PASSED |57 |
|By.name: message.text |should have(text 'long thread') |PASSED |47 |
|By.name: message.text |set value(Hello world!) |PASSED |69 |
|#send-button |click() |PASSED |1051 |
|.alert-success |should be(visible) |PASSED |71 |
+--------------------+-----------------------------------------------+--------+----------+
8. fast set value
mvn -Dselenide.fastSetValue=true
@Before public void setUp() {
Configuration.fastSetValue = true;
}
или
8. fast set value
И тогда $.setValue() использует JavaScript
● $.setValue(“john”) - быстро
● $.sendKeys(“john”) - для autocompletion
который гораздо быстрее!
Ты сам можешь выбирать:
Благодарности
● Alexandr Gavrilenko
Improved mechanism of closing webdrivers
● Sergey Shimkiv
Added method getWebDriverLogs()
Благодарности
● Vladimir Denisov @proton72
Added support for BrowserMob proxy
● kumarunster
Possibility to log important Selenide Actions
Статистика скачиваний
Уникальных IP
Андрей Солнцев
@asolntsev
ru.selenide.org
Спасибо!

Weitere ähnliche Inhalte

Andere mochten auch

Webium: Page Objects in Python
Webium: Page Objects in PythonWebium: Page Objects in Python
Webium: Page Objects in PythonIgor Khrol
 
The fast and the continuous (SeleniumCamp 2014)
The fast and the continuous (SeleniumCamp 2014)The fast and the continuous (SeleniumCamp 2014)
The fast and the continuous (SeleniumCamp 2014)Andrei Solntsev
 
The fast and the continuous - SQA Days 16
The fast and the continuous - SQA Days 16The fast and the continuous - SQA Days 16
The fast and the continuous - SQA Days 16Andrei Solntsev
 
Static website-generators
Static website-generatorsStatic website-generators
Static website-generatorsAndrei Solntsev
 
Android (Devclub.eu, 30.03.2010)
Android (Devclub.eu, 30.03.2010)Android (Devclub.eu, 30.03.2010)
Android (Devclub.eu, 30.03.2010)Andrei Solntsev
 
Functional Programming Dev Club 2009 - final
Functional Programming Dev Club 2009 - finalFunctional Programming Dev Club 2009 - final
Functional Programming Dev Club 2009 - finalAndrei Solntsev
 
50 оттенков play!
50 оттенков play!50 оттенков play!
50 оттенков play!Andrei Solntsev
 
Getting maximum from testing automation
Getting maximum from testing automationGetting maximum from testing automation
Getting maximum from testing automationAnton Sirota
 
архитектура Kotler ph. place marketing
архитектура Kotler ph. place marketingархитектура Kotler ph. place marketing
архитектура Kotler ph. place marketingДенис Семыкин
 
What is master @ SeleniumConf 2015
What is master @ SeleniumConf 2015What is master @ SeleniumConf 2015
What is master @ SeleniumConf 2015Andrei Solntsev
 
электронный учебник
электронный учебникэлектронный учебник
электронный учебникgaisha
 
Teaching Automation. How big companies do it.
Teaching Automation. How big companies do it.Teaching Automation. How big companies do it.
Teaching Automation. How big companies do it.Vitali Shulha
 
Write code for browsers with Scala
Write code for browsers with ScalaWrite code for browsers with Scala
Write code for browsers with ScalaGleb Kanterov
 
Agile.by Gathering – 23 января 2016
Agile.by Gathering – 23 января 2016Agile.by Gathering – 23 января 2016
Agile.by Gathering – 23 января 2016Igor Khrol
 

Andere mochten auch (20)

Webium: Page Objects in Python
Webium: Page Objects in PythonWebium: Page Objects in Python
Webium: Page Objects in Python
 
The Dangers of Cucumber
The Dangers of CucumberThe Dangers of Cucumber
The Dangers of Cucumber
 
The fast and the continuous (SeleniumCamp 2014)
The fast and the continuous (SeleniumCamp 2014)The fast and the continuous (SeleniumCamp 2014)
The fast and the continuous (SeleniumCamp 2014)
 
Real-life unit tests
Real-life unit testsReal-life unit tests
Real-life unit tests
 
The fast and the continuous - SQA Days 16
The fast and the continuous - SQA Days 16The fast and the continuous - SQA Days 16
The fast and the continuous - SQA Days 16
 
Static website-generators
Static website-generatorsStatic website-generators
Static website-generators
 
Android (Devclub.eu, 30.03.2010)
Android (Devclub.eu, 30.03.2010)Android (Devclub.eu, 30.03.2010)
Android (Devclub.eu, 30.03.2010)
 
WTF Code @ jug.lv
WTF Code @ jug.lvWTF Code @ jug.lv
WTF Code @ jug.lv
 
Functional Programming Dev Club 2009 - final
Functional Programming Dev Club 2009 - finalFunctional Programming Dev Club 2009 - final
Functional Programming Dev Club 2009 - final
 
50 оттенков play!
50 оттенков play!50 оттенков play!
50 оттенков play!
 
Getting maximum from testing automation
Getting maximum from testing automationGetting maximum from testing automation
Getting maximum from testing automation
 
архитектура Kotler ph. place marketing
архитектура Kotler ph. place marketingархитектура Kotler ph. place marketing
архитектура Kotler ph. place marketing
 
Simple life
Simple lifeSimple life
Simple life
 
What is master @ SeleniumConf 2015
What is master @ SeleniumConf 2015What is master @ SeleniumConf 2015
What is master @ SeleniumConf 2015
 
Extreme banking
Extreme bankingExtreme banking
Extreme banking
 
электронный учебник
электронный учебникэлектронный учебник
электронный учебник
 
Allure Framework
Allure FrameworkAllure Framework
Allure Framework
 
Teaching Automation. How big companies do it.
Teaching Automation. How big companies do it.Teaching Automation. How big companies do it.
Teaching Automation. How big companies do it.
 
Write code for browsers with Scala
Write code for browsers with ScalaWrite code for browsers with Scala
Write code for browsers with Scala
 
Agile.by Gathering – 23 января 2016
Agile.by Gathering – 23 января 2016Agile.by Gathering – 23 января 2016
Agile.by Gathering – 23 января 2016
 

Mehr von Andrei Solntsev

Тройничок: Selenide для Web, Android и iOS
Тройничок: Selenide для Web, Android и iOSТройничок: Selenide для Web, Android и iOS
Тройничок: Selenide для Web, Android и iOSAndrei Solntsev
 
Flaky tests. Метод.
Flaky tests. Метод. Flaky tests. Метод.
Flaky tests. Метод. Andrei Solntsev
 
Батл: Тесты или не тесты?
Батл: Тесты или не тесты?Батл: Тесты или не тесты?
Батл: Тесты или не тесты?Andrei Solntsev
 
Как получить чёрный пояс по программированию
Как получить чёрный пояс по программированиюКак получить чёрный пояс по программированию
Как получить чёрный пояс по программированиюAndrei Solntsev
 
Selenide puzzlers @ devclub.eu
Selenide puzzlers @ devclub.euSelenide puzzlers @ devclub.eu
Selenide puzzlers @ devclub.euAndrei Solntsev
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsAndrei Solntsev
 
Liquibase: Enterprise Edition
Liquibase: Enterprise EditionLiquibase: Enterprise Edition
Liquibase: Enterprise EditionAndrei Solntsev
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database DesignAndrei Solntsev
 
Functional Programming In Java
Functional Programming In JavaFunctional Programming In Java
Functional Programming In JavaAndrei Solntsev
 

Mehr von Andrei Solntsev (10)

Тройничок: Selenide для Web, Android и iOS
Тройничок: Selenide для Web, Android и iOSТройничок: Selenide для Web, Android и iOS
Тройничок: Selenide для Web, Android и iOS
 
Flaky tests. Метод.
Flaky tests. Метод. Flaky tests. Метод.
Flaky tests. Метод.
 
Батл: Тесты или не тесты?
Батл: Тесты или не тесты?Батл: Тесты или не тесты?
Батл: Тесты или не тесты?
 
Как получить чёрный пояс по программированию
Как получить чёрный пояс по программированиюКак получить чёрный пояс по программированию
Как получить чёрный пояс по программированию
 
Selenide puzzlers @ devclub.eu
Selenide puzzlers @ devclub.euSelenide puzzlers @ devclub.eu
Selenide puzzlers @ devclub.eu
 
Liquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOpsLiquibase & Flyway @ Baltic DevOps
Liquibase & Flyway @ Baltic DevOps
 
Liquibase: Enterprise Edition
Liquibase: Enterprise EditionLiquibase: Enterprise Edition
Liquibase: Enterprise Edition
 
Kiss.devclub ee.est
Kiss.devclub ee.estKiss.devclub ee.est
Kiss.devclub ee.est
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database Design
 
Functional Programming In Java
Functional Programming In JavaFunctional Programming In Java
Functional Programming In Java
 

Kürzlich hochgeladen (9)

ИСТОЧНИКИ ИННОВАЦИОННОСТИ КИТАЯ (ПО ВЕРСИИ DGAP) | The Sources of China’s Inn...
ИСТОЧНИКИ ИННОВАЦИОННОСТИ КИТАЯ (ПО ВЕРСИИ DGAP) | The Sources of China’s Inn...ИСТОЧНИКИ ИННОВАЦИОННОСТИ КИТАЯ (ПО ВЕРСИИ DGAP) | The Sources of China’s Inn...
ИСТОЧНИКИ ИННОВАЦИОННОСТИ КИТАЯ (ПО ВЕРСИИ DGAP) | The Sources of China’s Inn...
 
Cyber Defense Doctrine Managing the Risk Full Applied Guide to Organizational...
Cyber Defense Doctrine Managing the Risk Full Applied Guide to Organizational...Cyber Defense Doctrine Managing the Risk Full Applied Guide to Organizational...
Cyber Defense Doctrine Managing the Risk Full Applied Guide to Organizational...
 
CVE. The Fortra's GoAnywhere MFT [RU].pdf
CVE. The Fortra's GoAnywhere MFT [RU].pdfCVE. The Fortra's GoAnywhere MFT [RU].pdf
CVE. The Fortra's GoAnywhere MFT [RU].pdf
 
СИСТЕМА ОЦЕНКИ УЯЗВИМОСТЕЙ CVSS 4.0 / CVSS v4.0 [RU].pdf
СИСТЕМА ОЦЕНКИ УЯЗВИМОСТЕЙ CVSS 4.0 / CVSS v4.0 [RU].pdfСИСТЕМА ОЦЕНКИ УЯЗВИМОСТЕЙ CVSS 4.0 / CVSS v4.0 [RU].pdf
СИСТЕМА ОЦЕНКИ УЯЗВИМОСТЕЙ CVSS 4.0 / CVSS v4.0 [RU].pdf
 
MS Navigating Incident Response [RU].pdf
MS Navigating Incident Response [RU].pdfMS Navigating Incident Response [RU].pdf
MS Navigating Incident Response [RU].pdf
 
Malware. DCRAT (DARK CRYSTAL RAT) [RU].pdf
Malware. DCRAT (DARK CRYSTAL RAT) [RU].pdfMalware. DCRAT (DARK CRYSTAL RAT) [RU].pdf
Malware. DCRAT (DARK CRYSTAL RAT) [RU].pdf
 
2023 Q4. The Ransomware report. [RU].pdf
2023 Q4. The Ransomware report. [RU].pdf2023 Q4. The Ransomware report. [RU].pdf
2023 Q4. The Ransomware report. [RU].pdf
 
Cyberprint. Dark Pink Apt Group [RU].pdf
Cyberprint. Dark Pink Apt Group [RU].pdfCyberprint. Dark Pink Apt Group [RU].pdf
Cyberprint. Dark Pink Apt Group [RU].pdf
 
Ransomware_Q3 2023. The report [RU].pdf
Ransomware_Q3 2023.  The report [RU].pdfRansomware_Q3 2023.  The report [RU].pdf
Ransomware_Q3 2023. The report [RU].pdf
 

Good test = simple test (with selenide)