Time for action – hiding the welcome screen

When Eclipse starts, it typically displays a welcome page. Since this often gets in the way of automated user testing, it is useful to close this at startup.

  1. In the createProject() method, within a try block obtain a view with the title Welcome.
  2. Invoke the close() method.
  3. The code will change to look like this:
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    try {
      bot.viewByTitle("Welcome").close();
    }
    catch (WidgetNotFoundException e) {
      // ignore
    }
  4. Run the test—the welcome screen should be closed before the test is run.

What just happened?

Upon startup, the IDE will show a welcome screen. This is shown in a view with a Welcome title.

Using the viewByTitle() accessor, the SWTBot wrapper view can be accessed. If the view doesn't exist then an exception will be thrown for a safety check; catch any WidgetNotFoundException since not finding the welcome screen is not a failure.

Having found the welcome page, invoking the close() method will close the view.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset