Selecting a query in SQL file.

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Selecting a query in SQL file.

Postby Sonali » Mon Feb 11, 2008 6:24 am

Hi,

I am trying to record a test case which involves selecting a query from a sql file and then do a right click to get the
context menu.I tried selecting the query with a mouse which failed at the time of palyback,then i tried Ctrl+A and right click which again didnt give the expected result.

Could you please let me know how to achieve this?
Sonali
 
Posts: 4
Joined: Mon Jan 28, 2008 6:00 am

Re: Selecting a query in SQL file.

Postby Phil Quitslund » Mon Feb 11, 2008 8:55 am

Is the SQL file displayed in a text editor? Or a custom SQL editor?

Could you post the test the recorder generated?
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Selecting a query in SQL file.

Postby Sonali » Tue Feb 12, 2008 2:36 am

SQL file is displayed in a custom SQL editor.

In the test, i am connecting to a teradata database machine.Creating a sql file under a general project,selecting the connection details for sql file and then trying to choose the Execute selected text option in the context menu.

Here is the test generated by the recorder.The code in blue shows the selecting query part.(It selects using mouse).

public class SQLtest extends UITestCaseSWT {

/**
* Main test method.
*/
public void testSQLtest() throws Exception {
IUIContext ui = getUI();
ui.click(new XYLocator(new CTabItemLocator("Welcome"), 79, 14));
ui.click(new MenuItemLocator("Window/Open Perspective/Other..."));
ui.wait(new ShellShowingCondition("Open Perspective"));
ui.click(new TableItemLocator("Database Development"));
ui.click(new ButtonLocator("OK"));
ui.wait(new ShellDisposedCondition("Open Perspective"));
ui.contextClick(new TreeItemLocator("Databases",new ViewLocator(
"org.eclipse.datatools.connectivity.DataSourceExplorerNavigator")),"New...");
ui.wait(new ShellShowingCondition("New Connection Profile"));
ui.click(new TableItemLocator("Teradata Database"));
ui.click(new ButtonLocator("&Next >"));
ui.enterText("checks");
ui.click(new ButtonLocator("&Next >"));
ui.click(new LabeledLocator(Button.class,
"Select a driver from the drop-down:"));
ui.wait(new ShellShowingCondition("Driver Definitions"));
ui.click(new ButtonLocator("Add..."));
ui.wait(new ShellShowingCondition("New Driver Definition"));
ui.click(new TreeItemLocator(
"Database/Teradata Drivers/Teradata JDBC Driver",
new LabeledLocator(Tree.class, "Available Driver Templates")));
ui.click(new ButtonLocator("OK"));
ui.wait(new ShellDisposedCondition("New Driver Definition"));
ui.wait(new ShellShowingCondition("Edit Driver Definition"));
ui.click(new TreeItemLocator("General/Connection URL"));
ui.click(new XYLocator(new SWTWidgetLocator(Text.class,
new SWTWidgetLocator(Tree.class)), 127, 9));
ui.enterText("checks");
ui.click(new TreeItemLocator("General/Database Name"));
ui.enterText("ide");
ui.click(new LabeledLocator(Composite.class, "Properties:"));
ui.click(new TreeItemLocator("General/Password"));
ui.enterText("dbc");
ui.click(new TreeItemLocator("General/User ID"));
ui.enterText("dbc");
ui.click(new ButtonLocator("OK"));
ui.wait(new ShellDisposedCondition("Edit Driver Definition"));
ui.click(new TreeItemLocator(
"Database/Teradata Drivers/Teradata JDBC Driver"));
ui.click(new ButtonLocator("OK"));
ui.wait(new ShellDisposedCondition("Driver Definitions"));
ui.click(new SWTWidgetLocator(Text.class, new LabeledLocator(
Composite.class, "Database Server Name:")));
ui.enterText("checks");
ui.click(new ButtonLocator("&Next >"));
ui.click(new ButtonLocator("&Finish"));
ui.wait(new ShellDisposedCondition("New Teradata Connection Profile"));
ui.contextClick(new TreeItemLocator("Databases/checks",new ViewLocator(
"org.eclipse.datatools.connectivity.DataSourceExplorerNavigator")),"Connect");
ui.wait(new ShellShowingCondition("Creating connections to checks."));
ui.wait(new ShellShowingCondition(
"Creating SQL Model Connection connection to checks."));
ui.wait(new ShellShowingCondition("Refreshing View"));
ui.wait(new ShellDisposedCondition(
"Creating SQL Model Connection connection to checks."));
ui.wait(new ShellDisposedCondition("Creating connections to checks."));
ui.wait(new ShellDisposedCondition("Refreshing View"));
ui.click(new MenuItemLocator("File/New/Project..."));
ui.wait(new ShellShowingCondition("New Project"));
ui.click(new TreeItemLocator("Java Project"));
ui.click(new TreeItemLocator("General/Project"));
ui.click(new ButtonLocator("&Next >"));
ui.click(new LabeledTextLocator("&Project name:"));
ui.enterText("SQL");
ui.click(new ButtonLocator("&Finish"));
ui.wait(new ShellDisposedCondition("Progress Information"));
ui.wait(new ShellDisposedCondition("New Project"));
ui.click(new MenuItemLocator("Window/Open Perspective/Other..."));
ui.wait(new ShellShowingCondition("Open Perspective"));
ui.click(new TableItemLocator("Java (default)"));
ui.click(new ButtonLocator("OK"));
ui.wait(new ShellDisposedCondition("Open Perspective"));
ui.contextClick(new TreeItemLocator("SQL", new ViewLocator(
"org.eclipse.jdt.ui.PackageExplorer")), "New/File");
ui.wait(new ShellShowingCondition("New File"));
ui.click(new LabeledTextLocator("File na&me:"));
ui.enterText("sql1.sql");
ui.click(new ButtonLocator("&Finish"));
ui.wait(new ShellDisposedCondition("Progress Information"));
ui.wait(new ShellDisposedCondition("New File"));
ui.click(new MenuItemLocator("Window/Open Perspective/Other..."));
ui.wait(new ShellShowingCondition("Open Perspective"));
ui.click(new TableItemLocator("Database Development"));
ui.click(new ButtonLocator("OK"));
ui.wait(new ShellDisposedCondition("Open Perspective"));
ui.click(new ComboItemLocator("Teradata_6.1", new SWTWidgetLocator(
Combo.class, 0, new SWTWidgetLocator(Group.class,
"Connection &profile"))));
ui.click(new ComboItemLocator("checks", new SWTWidgetLocator(
Combo.class, new LabeledLocator(Composite.class, "&Name:"))));
ui.click(new ComboItemLocator("ide", new SWTWidgetLocator(Combo.class,
1, new SWTWidgetLocator(Group.class, "Connection &profile"))));
ui.click(new SWTWidgetLocator(StyledText.class));
ui.enterText("select ");
ui.wait(new ShellShowingCondition(""));
ui.enterText("* from dbc.dbcinfo;");
ui.click(new XYLocator(new SWTWidgetLocator(StyledText.class), 13, 58));
ui.click(new XYLocator(new SWTWidgetLocator(StyledText.class), -7, 6));
ui.contextClick(new SWTWidgetLocator(StyledText.class),"Execute Selected Text");
ui.wait(new ShellShowingCondition("Teradata SQL Statement Execution"));
}
}
Sonali
 
Posts: 4
Joined: Mon Jan 28, 2008 6:00 am

Re: Selecting a query in SQL file.

Postby Phil Quitslund » Tue Feb 12, 2008 8:01 am

What happens if you insert the CTRL-A click manually?

Code: Select all
ui.click(new SWTWidgetLocator(StyledText.class));
ui.enterText("select ");
ui.enterText("* from dbc.dbcinfo;");
ui.keyClick(WT.CTRL, 'a'); //<--- insert CTRL-A click here
ui.contextClick(new SWTWidgetLocator(StyledText.class),"Execute Selected Text");

Does this work? (The recorder does not see global actions such as Ctrl-clicks since they are consumed by a global action handler and never reach the display... If you want to record the selction, you might use a menu item if there is one?)
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest