Download - Polyglot automation - QA Fest - 2015
![Page 1: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/1.jpg)
Polyglot Automation
@yashaka
![Page 2: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/2.jpg)
Preface…
@yashaka
![Page 3: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/3.jpg)
What Language?
![Page 4: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/4.jpg)
Automation =
Automating manual routine work
![Page 5: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/5.jpg)
Automation => QA ???
![Page 6: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/6.jpg)
Effective Automation => QA
![Page 7: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/7.jpg)
Polyglot Automation=
Using Any Language to make it Effective
![Page 8: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/8.jpg)
Effective Automation *=
with Backend Language
Web UI
![Page 9: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/9.jpg)
Why?
![Page 10: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/10.jpg)
Developers can help with implementation
Easier for devs to use and support tests
Smaller Tech Stack. No Zoo at project :)
And…
![Page 11: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/11.jpg)
Allows to use fast & efficient test data pre-setup!
![Page 12: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/12.jpg)
Demo
![Page 13: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/13.jpg)
![Page 14: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/14.jpg)
Full coverage for TodoMVC:
Without “backend” preconditions: 24s
With “backend” preconditions: 16s
=> optimised for 30%
![Page 15: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/15.jpg)
A remark
TodoMVC is very simple app with small lightweight “preconditions” in tests
Real app will usually have much more “hardweight” preconditions
So the optimisation may be much bigger
![Page 16: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/16.jpg)
But it’s hard, no?
![Page 17: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/17.jpg)
Hard to:
learn new language…
use statically typed Java/C# over dynamic Python/Ruby…
?
![Page 18: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/18.jpg)
No:p
![Page 19: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/19.jpg)
No:pif you use “easy tools” ;)
![Page 20: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/20.jpg)
Examples
![Page 21: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/21.jpg)
![Page 22: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/22.jpg)
Tests
![Page 23: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/23.jpg)
public class TodoMVCTest { @Test public void testFilterTasks(){
Tasks.visit();
Tasks.add("a", "b", "c"); Tasks.shouldBe("a", "b", "c");
Tasks.toggle("b");
Tasks.filterActive (); Tasks.shouldBe("a", "c");
Tasks.filterCompleted (); Tasks.shouldBe("b"); }}
![Page 24: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/24.jpg)
[TestFixture ()]public class Test : BaseTest { [Test ()] public void FilterTasks () { Tasks.Visit ();
Tasks.Add ("a", "b", "c"); Tasks.ShouldBe ("a", "b", "c");
Tasks.Toggle ("b");
Tasks.FilterActive (); Tasks.ShouldBe ("a", "c");
Tasks.FilterCompleted (); Tasks.ShouldBe ("b"); }}
![Page 25: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/25.jpg)
class TestTodoMVC(BaseTest): def test_filter_tasks(self):
tasks.visit()
tasks.add("a", "b", "c") tasks.should_be("a", "b", "c")
tasks.toggle("b")
tasks.filter_active () tasks.should_be("a", "c")
tasks.filter_completed () tasks.should_be("b")
![Page 26: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/26.jpg)
describe "todomvc" do it "filters tasks" do
Tasks.open
Tasks.add "a", "b", "c" Tasks.should_be "a", "b", "c"
Tasks.toggle "b"
Tasks.filter_active Tasks.should_be "a", "c"
Tasks.filter_completed Tasks.should_be "b" endend
![Page 27: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/27.jpg)
Helperssimpler
![Page 28: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/28.jpg)
public class Tasks { ... public static void visit() {
open("https://todomvc4tasj.herokuapp.com/"); } public static void filterActive(){
$(By.linkText("Active")).click(); } public static void filterCompleted(){
$(By.linkText("Completed")).click(); } public static void add(String... taskTexts) {
for(String text: taskTexts){
$("#new-todo").setValue(text).pressEnter(); } } ...}
![Page 29: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/29.jpg)
public static class Tasks{ ... public static void Visit() {
Open ("https://todomvc4tasj.herokuapp.com/"); } public static void FilterActive () {
S (By.LinkText ("Active")).Click (); } public static void FilterCompleted () {
S (By.LinkText ("Completed")).Click (); } public static void Add(params string[] taskTexts) {
foreach (var text in taskTexts) {
S ("#new-todo").SetValue (text).PressEnter (); } } ...}
![Page 30: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/30.jpg)
…
def visit():
tools.visit("https://todomvc4tasj.herokuapp.com/")def filter_active():
s(by_link_text(”Active”)).click()def filter_completed():
s(by_link_text(”Completed”)).click()def add(*task_texts):
for text in task_texts:
s("#new-todo").set_value(text).press_enter()
![Page 31: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/31.jpg)
module Tasks extend Capybara::DSL def self.open
visit 'https://todomvc4tasj.herokuapp.com' end def self.filter_active
find("a", text:"Active").click end def self.filter_completed
find("a", text:"Completed").click end def self.add *task_texts
task_texts.each do |text|
find("#new-todo").send_keys(text, :enter) end end ...end
![Page 32: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/32.jpg)
Helpersa bit harder
![Page 33: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/33.jpg)
public class Tasks {
public static ElementsCollection tasks = $$("#todo-list>li"); ... public static void toggle(String taskText) { tasks.findBy(exactText(taskText)).find(".toggle").click(); } public static void shouldBe(String... taskTexts) { tasks.filterBy(visible).shouldHave(exactTexts(taskTexts)); }}
![Page 34: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/34.jpg)
public static class Tasks{ public static SCollection List = SS ("#todo-list>li"); ... public static void Toggle (string taskText) { List.FindBy (Have.ExactText(taskText)).Find (".toggle").Click(); } public static void ShouldBe(params string[] names) { List.FilterBy (Be.Visible).Should (Have.Texts (names)); }}
![Page 35: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/35.jpg)
tasks = ss("#todo-list>li")...
def toggle(task_text): tasks.findBy(exact_text(task_text)).find(".toggle").click() def should_be(*task_texts): tasks.filterBy(visible).should_have(exact_texts(*task_texts))
![Page 36: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/36.jpg)
module Tasks extend Capybara::DSL def self.tasks all "#todo-list>li" end ... def self.toggle task_text
(tasks.findBy {|task| task.text == task_text}).find(".toggle").click end def self.should_be *task_texts tasks.texts.should == task_texts endend
![Page 37: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/37.jpg)
Easy?
![Page 38: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/38.jpg)
Easy Tools?
![Page 39: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/39.jpg)
Java: Selenide
Python: Selene is coming…
C#: NSelene is coming…
Ruby: Capybara
? JavaScript: Protractor
? PHP: Codeception
![Page 40: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/40.jpg)
No ready Easy Tool for your language?
Lack of knowledge?
=> ask project’s developers to write it for you
Brave?
=> implement it by your own
![Page 41: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/41.jpg)
How to become polyglot automation engineer?
Just learn ONE Language perfectly.
Then
Don’t be afraid to switch to other when it fits better
![Page 42: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/42.jpg)
Learn next language
learnxinyminutes.com +
koans +
practice solving common tasks +
google.com
![Page 43: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/43.jpg)
AfterwordsThere are good practices in context,
but there are no best practices. (c) Cem Kaner, James Bach
![Page 44: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/44.jpg)
Q&A
![Page 45: Polyglot automation - QA Fest - 2015](https://reader034.vdocuments.mx/reader034/viewer/2022042619/58ec35961a28ab70288b46a9/html5/thumbnails/45.jpg)
github.com/yashaka
youtube.com/c/ItlabsNetUa
gitter.im/yashaka/better-selenium
[email protected] @yashaka