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.
In the
createProject()
method, within atry
block obtain a view with the titleWelcome
.Invoke the
close()
method.The code will change to look like this:
SWTWorkbenchBot bot = new SWTWorkbenchBot(); try { bot.viewByTitle("Welcome").close(); } catch (WidgetNotFoundException e) { // ignore }
Run the test—the welcome screen should be closed before the test is run.
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...