SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Downloaden Sie, um offline zu lesen
Web UI Tests Examples
with
Selenide, nSelene, Selene & Capybara
http://todomvc4tasj.herokuapp.com
Tests
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");

}

}
[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");

}

}
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")
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"

end

end
Step-Helpers
simpler
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();

}

}
...

}
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 ();

}

}
...

}
…
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()
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



...

Step-Helpers
a bit harder
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));

}

}
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));

}

}
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))
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

end

end
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

end

end
is == above ;)==
Easy?
Easy Tools
http://selenide.org
https://github.com/jnicklas/capybara
https://github.com/yashaka/selene
https://github.com/yashaka/NSelene
github.com/yashaka
twitter.com/yashaka
yashaka@gmail.com
Thank You

Weitere ähnliche Inhalte

Was ist angesagt?

Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
Andy Peterson
 

Was ist angesagt? (20)

Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
 
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order component
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
Basic Tutorial of React for Programmers
Basic Tutorial of React for ProgrammersBasic Tutorial of React for Programmers
Basic Tutorial of React for Programmers
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
 
軟體測試是在測試什麼?
軟體測試是在測試什麼?軟體測試是在測試什麼?
軟體測試是在測試什麼?
 
Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App
 
Adventures In JavaScript Testing
Adventures In JavaScript TestingAdventures In JavaScript Testing
Adventures In JavaScript Testing
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
Protractor Training in Pune by QuickITDotnet
Protractor Training in Pune by QuickITDotnet Protractor Training in Pune by QuickITDotnet
Protractor Training in Pune by QuickITDotnet
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Night Watch with QA
Night Watch with QANight Watch with QA
Night Watch with QA
 
The Screenplay Pattern: Better Interactions for Better Automation
The Screenplay Pattern: Better Interactions for Better AutomationThe Screenplay Pattern: Better Interactions for Better Automation
The Screenplay Pattern: Better Interactions for Better Automation
 
Testing in AngularJS
Testing in AngularJSTesting in AngularJS
Testing in AngularJS
 
Droidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offlineDroidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offline
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Getting to Grips with SilverStripe Testing
Getting to Grips with SilverStripe TestingGetting to Grips with SilverStripe Testing
Getting to Grips with SilverStripe Testing
 
Ember testing internals with ember cli
Ember testing internals with ember cliEmber testing internals with ember cli
Ember testing internals with ember cli
 
Revolution or Evolution in Page Object
Revolution or Evolution in Page ObjectRevolution or Evolution in Page Object
Revolution or Evolution in Page Object
 
Test like a pro with Ember.js
Test like a pro with Ember.jsTest like a pro with Ember.js
Test like a pro with Ember.js
 

Andere mochten auch

QA Fest 2016. Яков Крамаренко. Укрощаем фреймворки-динозавры используя NSelene
QA Fest 2016. Яков Крамаренко. Укрощаем фреймворки-динозавры используя NSeleneQA Fest 2016. Яков Крамаренко. Укрощаем фреймворки-динозавры используя NSelene
QA Fest 2016. Яков Крамаренко. Укрощаем фреймворки-динозавры используя NSelene
QAFest
 
Pivotal Failure - Lessons Learned from Lean Startup Machine DC
Pivotal Failure - Lessons Learned from Lean Startup Machine DCPivotal Failure - Lessons Learned from Lean Startup Machine DC
Pivotal Failure - Lessons Learned from Lean Startup Machine DC
Dave Haeffner
 
Agile testing for mere mortals
Agile testing for mere mortalsAgile testing for mere mortals
Agile testing for mere mortals
Dave Haeffner
 

Andere mochten auch (17)

Write Selenide in Python 15 min
Write Selenide in Python 15 minWrite Selenide in Python 15 min
Write Selenide in Python 15 min
 
Automation is Easy! (python version)
Automation is Easy! (python version)Automation is Easy! (python version)
Automation is Easy! (python version)
 
QA Fest 2016. Яков Крамаренко. Укрощаем фреймворки-динозавры используя NSelene
QA Fest 2016. Яков Крамаренко. Укрощаем фреймворки-динозавры используя NSeleneQA Fest 2016. Яков Крамаренко. Укрощаем фреймворки-динозавры используя NSelene
QA Fest 2016. Яков Крамаренко. Укрощаем фреймворки-динозавры используя NSelene
 
Better Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component PatternBetter Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component Pattern
 
Web testing with Selenium
Web testing with SeleniumWeb testing with Selenium
Web testing with Selenium
 
Pivotal Failure - Lessons Learned from Lean Startup Machine DC
Pivotal Failure - Lessons Learned from Lean Startup Machine DCPivotal Failure - Lessons Learned from Lean Startup Machine DC
Pivotal Failure - Lessons Learned from Lean Startup Machine DC
 
Continuous Testing Meets the Classroom at Code.org
Continuous Testing Meets the Classroom at Code.orgContinuous Testing Meets the Classroom at Code.org
Continuous Testing Meets the Classroom at Code.org
 
Selenium
SeleniumSelenium
Selenium
 
Full Stack Testing Done Well
Full Stack Testing Done WellFull Stack Testing Done Well
Full Stack Testing Done Well
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Agile testing for mere mortals
Agile testing for mere mortalsAgile testing for mere mortals
Agile testing for mere mortals
 
The Testable Web
The Testable WebThe Testable Web
The Testable Web
 
Selenium Basics
Selenium BasicsSelenium Basics
Selenium Basics
 
Cross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToCross Platform Appium Tests: How To
Cross Platform Appium Tests: How To
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Bdd lessons-learned
Bdd lessons-learnedBdd lessons-learned
Bdd lessons-learned
 
Selenium Users Anonymous
Selenium Users AnonymousSelenium Users Anonymous
Selenium Users Anonymous
 

Ähnlich wie Web ui tests examples with selenide, nselene, selene & capybara

WuKong - Framework for Integrated Test
WuKong - Framework for Integrated TestWuKong - Framework for Integrated Test
WuKong - Framework for Integrated Test
Summer Lu
 

Ähnlich wie Web ui tests examples with selenide, nselene, selene & capybara (20)

Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developers
 
Google guava
Google guavaGoogle guava
Google guava
 
Роман Иовлев «Open Source UI Automation Tests on C#»
Роман Иовлев «Open Source UI Automation Tests on C#»Роман Иовлев «Open Source UI Automation Tests on C#»
Роман Иовлев «Open Source UI Automation Tests on C#»
 
Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4
 
Future of UI Automation testing and JDI
Future of UI Automation testing and JDIFuture of UI Automation testing and JDI
Future of UI Automation testing and JDI
 
Roman iovlev. Test UI with JDI - Selenium camp
Roman iovlev. Test UI with JDI - Selenium campRoman iovlev. Test UI with JDI - Selenium camp
Roman iovlev. Test UI with JDI - Selenium camp
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testing
 
WuKong - Framework for Integrated Test
WuKong - Framework for Integrated TestWuKong - Framework for Integrated Test
WuKong - Framework for Integrated Test
 
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistJEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with Javassist
 
apache tajo 연동 개발 후기
apache tajo 연동 개발 후기apache tajo 연동 개발 후기
apache tajo 연동 개발 후기
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Guide to the jungle of testing frameworks
Guide to the jungle of testing frameworksGuide to the jungle of testing frameworks
Guide to the jungle of testing frameworks
 
Core java Essentials
Core java EssentialsCore java Essentials
Core java Essentials
 
SWTBot Tutorial
SWTBot TutorialSWTBot Tutorial
SWTBot Tutorial
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
guice-servlet
guice-servletguice-servlet
guice-servlet
 
QA Fest 2015. Яков Крамаренко. Polyglot automation
QA Fest 2015. Яков Крамаренко. Polyglot automation QA Fest 2015. Яков Крамаренко. Polyglot automation
QA Fest 2015. Яков Крамаренко. Polyglot automation
 
servlets
servletsservlets
servlets
 
Not your father's tests
Not your father's testsNot your father's tests
Not your father's tests
 
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Web ui tests examples with selenide, nselene, selene & capybara

  • 1. Web UI Tests Examples with Selenide, nSelene, Selene & Capybara
  • 4. 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");
 }
 }
  • 5. [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");
 }
 }
  • 6. 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")
  • 7. 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"
 end
 end
  • 9. 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();
 }
 } ...
 }
  • 10. 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 ();
 }
 } ...
 }
  • 11. … 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()
  • 12. 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
 
 ...

  • 14. 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));
 }
 }
  • 15. 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));
 }
 }
  • 16. 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))
  • 17. 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
 end
 end
  • 18. 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
 end
 end is == above ;)==
  • 19. Easy?