To show other views, the same mechanism is followed in the UI tests, as a user would do; by going to Window | Show View | Other.
testTimeZoneView()
, with a @Test
annotation.bot.viewByTitle()
method to acquire a reference to the view.null
.@Test public void testTimeZoneView() { bot.menu("Window").menu("Show View").menu("Other...").click(); SWTBotShell shell = bot.shell("Show View"); shell.activate(); bot.tree().expandNode("Timekeeping").select("Time Zone View"); bot.button("OK").click(); SWTBotView timeZoneView = bot.viewByTitle("Time Zone View"); assertNotNull(timeZoneView); }
Using the built-in Eclipse mechanism to switch views, the bot navigated to the Time Zone View menu inside Window | Show View | Other | Timekeeping to bring the view to the screen.
Once shown, the viewByTitle()
method of the bot can be used to get a reference to the widget; verify that it is not null
.
Being able to select a view programmatically is such a common occurrence that it can help to have a utility method to open a view on demand.