SlideShare a Scribd company logo
1 of 12
Automated testing – Selenium #2

             Peter Šimún
             @petersimun
Zadefinujte si pravidlá!

nedovoľte, aby sa porušovali

  a váš život bude skvelý




         jedine, že by nie
Pravidlo č.1: Shaolinských mníchov

               Všetko neotestujete, aj
              keď sa na hlavu postavíte
Pozor! Nasleduje kód!
Pravidlo č.2: Striktná a dôkladná architektúra


                               Express your tests in the
                                       language
                               of the end-user of the app



                                 Ubiquitous Language


                                 Domain driven design
Prihlásiť sa do synapsa
Pridať prázdnu stránku
Pridať twitter komponent - @webelement
Pridať twitter komponent - @petersimun
Vycentrovať twitter komponenty na stred stránky
Presunúť druhý twitter komponent (@petersimun) pred prvý twitter komponent
(@webelement)
Overiť výsledok na stránke – správne poradie twitter komponentov, pozícia na
stránke


                     Express your tests in the
                              language
                     of the end-user of the app
loginSupport.login(new UsernamePasswordUser(Role.ADMIN));
pageSupport.addBlankPage(new
Page().randomize(seleniumSupport));
Twitter twitter_ps = new Twitter("petersimun");
Twitter twitter_we = new Twitter("webelement");
toolbarSupport.clickAndWait(Module.COMPONENT);
twitterSupport.createTwitter (twitter_we);
twitterSupport.centerTwitter(twitter_we);
twitterSupport.createTwitter (twitter_ps);
twitterSupport.centerTwitter(twitter_ps);
twitterSupport.moveTwitterToPosition(twitter_we, new
Position(0, 100));
public class Twitter implements WebElement {

    private String twitterAccount = "synapso";
    private int twittsCounts = 5;
    public Twitter (String twitterAccount) {
        this.twitterAccount = twitterAccount;
    }
    public String getTwitterAccount() {
        return twitterAccount;
    }
    public WebElement getTwitterElement() {
        return twitterElement;
    }



 obyčajné POJO
 predstavuje vstupné podmienky testu
 mapuje sa a zobrazuje na UI
public class TwitterPage {
    public By getTwitterSelector() {
        return By.xpath("//div[contains(@class,'twitterWidget') and
                          contains(@class,'floatClear')]//ul");
    }
    public By getTweetSelector(String source) {
        return By.xpath("//div[contains(@class,'twitterWidget
               floatClear') and contains(@source,'" + source
                          + "')]//ul//li[position() = 1]");
    }
    public By getTwitterInputSelector() {
        return By.xpath("//div[contains(@class,'acris-metal-
               dialog')]//input[contains(@class,'gwt-Text')]");
    }
}

reprezentuje UI komponenty pomocou selectorov
ak sa niečo zmení na UI, zmenu treba pravdepodobne reflektovať na tomto
mieste
Ak nechcete skončiť v pekle, nepoužívajte selectory v testoch alebo v support
triedach!!
public class UsernamePasswordLoginSupport implements LoginSupport
{
    @Override
    public void login(UserData userData, Language language) {
    }
        @Override
    public void login(UserData user) {
    }
    @Override
    public void logout() {
    }
    ...
}
Písaný v jazyku zrozumiteľnom pre ľudí ( developer ≠ človek )
Úzko komunikuje so selenium a zaobaluje znovupoužiteľnú funkcionalitu do
metód
Nerobte pikoniny a nestestujte až keď horí
@petersimun



         Seges s.r.o.
Lombardíniho 20, 831 03 Bratislava
   tel. +421 (0)2 206 333 69
        office@seges.sk
         www.seges.sk

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Selenium prezentácia pre Webelement

  • 1. Automated testing – Selenium #2 Peter Šimún @petersimun
  • 2. Zadefinujte si pravidlá! nedovoľte, aby sa porušovali a váš život bude skvelý jedine, že by nie
  • 3. Pravidlo č.1: Shaolinských mníchov Všetko neotestujete, aj keď sa na hlavu postavíte
  • 5. Pravidlo č.2: Striktná a dôkladná architektúra Express your tests in the language of the end-user of the app Ubiquitous Language Domain driven design
  • 6. Prihlásiť sa do synapsa Pridať prázdnu stránku Pridať twitter komponent - @webelement Pridať twitter komponent - @petersimun Vycentrovať twitter komponenty na stred stránky Presunúť druhý twitter komponent (@petersimun) pred prvý twitter komponent (@webelement) Overiť výsledok na stránke – správne poradie twitter komponentov, pozícia na stránke Express your tests in the language of the end-user of the app
  • 7. loginSupport.login(new UsernamePasswordUser(Role.ADMIN)); pageSupport.addBlankPage(new Page().randomize(seleniumSupport)); Twitter twitter_ps = new Twitter("petersimun"); Twitter twitter_we = new Twitter("webelement"); toolbarSupport.clickAndWait(Module.COMPONENT); twitterSupport.createTwitter (twitter_we); twitterSupport.centerTwitter(twitter_we); twitterSupport.createTwitter (twitter_ps); twitterSupport.centerTwitter(twitter_ps); twitterSupport.moveTwitterToPosition(twitter_we, new Position(0, 100));
  • 8. public class Twitter implements WebElement { private String twitterAccount = "synapso"; private int twittsCounts = 5; public Twitter (String twitterAccount) { this.twitterAccount = twitterAccount; } public String getTwitterAccount() { return twitterAccount; } public WebElement getTwitterElement() { return twitterElement; } obyčajné POJO predstavuje vstupné podmienky testu mapuje sa a zobrazuje na UI
  • 9. public class TwitterPage { public By getTwitterSelector() { return By.xpath("//div[contains(@class,'twitterWidget') and contains(@class,'floatClear')]//ul"); } public By getTweetSelector(String source) { return By.xpath("//div[contains(@class,'twitterWidget floatClear') and contains(@source,'" + source + "')]//ul//li[position() = 1]"); } public By getTwitterInputSelector() { return By.xpath("//div[contains(@class,'acris-metal- dialog')]//input[contains(@class,'gwt-Text')]"); } } reprezentuje UI komponenty pomocou selectorov ak sa niečo zmení na UI, zmenu treba pravdepodobne reflektovať na tomto mieste Ak nechcete skončiť v pekle, nepoužívajte selectory v testoch alebo v support triedach!!
  • 10. public class UsernamePasswordLoginSupport implements LoginSupport { @Override public void login(UserData userData, Language language) { } @Override public void login(UserData user) { } @Override public void logout() { } ... } Písaný v jazyku zrozumiteľnom pre ľudí ( developer ≠ človek ) Úzko komunikuje so selenium a zaobaluje znovupoužiteľnú funkcionalitu do metód
  • 11. Nerobte pikoniny a nestestujte až keď horí
  • 12. @petersimun Seges s.r.o. Lombardíniho 20, 831 03 Bratislava tel. +421 (0)2 206 333 69 office@seges.sk www.seges.sk