• Home

  • Courses

    • Run Java Selenium Tests in Azure Devops
    • Interviewing for Testing Positions
  • For Business

  • Trainings

    • Beginner Selenium (May 2018)
    • Advanced Selenium (Feb 2019)
  • Teacher

  • Bootcamp Info

  • Forum

  • Blog

  • Meetups

    • Test Automation for Responsive Site
    • All about Locators in Selenium Projects
  • More..

    • FAQ
    • Cheat Sheets
    • Presentations
  • More...

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    alexsiminiuc3
    May 27, 2018

    Do not open the site in the setUp() method

    in Selenium Questions

    If you include in the setUp() method code that opens the site, for example,


    @BeforeTest
    public void setUp() {
      System.setProperty("webdriver.chrome.driver", 
                         "c:/selenium/chromedriver.exe");
      driver = new ChromeDriver();
      driver.get(URL);
      searchForKeyword(keyword);	
    }

    all test methods will have to start with opening the home page and running a keyword search.


    If one of the tests will prefer to start on a diferent page, this will not be possible.


    It is better to just set up the environment in the setUp() method and move all code that interacts with the site in each test method:


    @BeforeTest
    public void setUp() {
       System.setProperty("webdriver.chrome.driver", 
                          "c:/selenium/chromedriver.exe");
       driver = new ChromeDriver();
    }


    0 comments
    0
    Comments

    Share Your ThoughtsSign up to leave a comment.

    0 comments

    © 2021 Vancouver Selenium WebDriver Automation Training