Friday, August 27, 2010

Oracle Dates and Timestamps

Date/Timestamps in Oracle make be break out into hives. And then I start to miss MS SQL Server.....a little.

Oracle does not like to return timestamps when querying date/time fields; so sometimes I have to use something like this:

SELECT to_char(to_timestamp(to_char(a.fieldName, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS'))
FROM tableName a

Saturday, August 7, 2010

SpiraTest Tips

  • Make your test case names as short as possible. On some screens, SpiraTest only shows so many characters of the test name, so shorter is better.
  • I had trouble changing the font on the Test Steps. I had to view the step in HTML (a button when you're editing the step) and edit the HTML to change the fonts. I pretty much gave up on doing this b/c it's a waste of time.
  • Be careful navigating away from a test you are writing. SpiraTest will not warn you that you haven't saved your changes.
  • On the Test List screen, "Show Level" may need to be changed in order to view all tests

Non-Invasive VPN

If you need to route only certain traffic over a VPN connection, do the following:
  1. After setting up the VPN connection, open up the Connect screen.
  2. Click on Properties and go to the "Networking" tab.
  3. Select Internet Protocol and click on Properties.
  4. Click Advanced and go to the "General" tab.
  5. Uncheck "Use default gateway on remote network."
  6. Click OK 3 times to get back to the connect window.
  7. Connect.
  8. Open a command prompt and run ipconfig to see what IP the VPN server assigned you.
  9. Run the following command: route add 192.62.174.0 MASK 255.255.255.0
Replace  with the actual IP the VPN assigned you.
    For example, if I were assigned IP 192.168.0.216, I'd run this command: route add 192.62.174.0 MASK 255.255.255.0 192.168.0.216
    .

    Checkboxes and Selenium

    When checking (or unchecking) a checkbox, Selenium IDE might record something like this:
    click - chckbx_0_0
    Both the command and the location are ambiguous.

    For example, let's say you're trying to
    uncheck BoxA. "Click" is ambiguous because if BoxA is already unchecked, you'll check it by clicking the checkbox. "chckbx_0_0" is ambiguous as a locator because if checkboxes are added or removed from the screen in the future, "chckbx_0_0" could identify a different checkbox.

    Use this instead:
    command = uncheck (or check)
    target (location) = relative xPath of the checkbox element

    Of course, Selenium IDE recorded ambiguously on my project in this particular scenario. It will record differently depending on the application.

    XPath and Selenium Locator Information

    I often need to use a relative XPath to locate elements in Selenium. A few reasons to use relative XPath:
    1. The ID of the element changes every time you go to the page.
    2. You suspect the element could change location in the future and the locator recorded by Selenium IDE is too ambiguous to handle changes in the future.
    Here's some excellent information on Locators in Selenium: http://seleniumhq.org/docs/02_selenium_ide.html#locating-elements

    I often refer to http://www.w3.org/TR/xpath/ , particularly sections 2 Location Paths, 2.2 Axes, 2.5 Abbreviated Syntax.

    Creating an Oracle database and importing a dump file

    It's not too often that I need to create a new database. Since I rarely do this, I wanted to jot down some notes for next time. Thanks to the developer/dba for the help. Of course, these steps will vary a little depending on what you want to do.

    One way to create an Oracle db using Windows:
    (I created an 11g db)
    1. Open DBCA (probably in C:\Oracle\product\11.1.0\db_1\BIN).
    2. Hit Next.
    3. Select Create a Database and hit Next.
    4. Select General Purpose or Transaction Processing and hit Next.
    5. Enter a Global Database Name (use this as your SID) and hit Next.
    6. Unselect Configure Enterprise Manager and hit Next.
    7. Select Use the Same Administrative Password for All Accounts and enter ‘password’ in each box. Click Next.
    8. Click Finish.
    9. Click OK on the box that pops up.
    10. After the database creates successfully, exit DBCA.
    After creating the database, I needed to import a dump file. So first I had to set up the import directory, and some tablespaces and roles needed for the import.

    In this example, 'C:\tmp' is my import directory, where the dump file is located:

    CREATE OR REPLACE DIRECTORY import_dir AS 'C:\tmp';

    COMMIT;

    I needed to setup a profile for my db:

    CREATE PROFILE APP_PROFILE

    LIMIT FAILED_LOGIN_ATTEMPTS 10

    PASSWORD_LIFE_TIME 180

    PASSWORD_LOCK_TIME 1

    PASSWORD_GRACE_TIME 7;

    COMMIT;

    Examples of setting up tablespaces and roles:

    CREATE TABLESPACE TABLE_INDEX01 DATAFILE 'C:\Oracle\oradata\[insert SID here]\table_index01.dbf' SIZE 1000m AUTOEXTEND ON MAXSIZE 2000m EXTENT MANAGEMENT LOCAL UNIFORM SIZE 5m;

    COMMIT;

    CREATE ROLE TEST_DBA IDENTIFIED BY TEST_DBA;

    COMMIT;

    Then I ran the following command to import the dump file:

    %ORACLE_HOME%\bin\impdp system/password full=y directory=import_dir dumpfile=name_of_dump_file.dmp nologfile=Y

    You can use the DBCA tool to delete databases also.

    When I tried to connect to my new database in SQL Developer, I ran into some errors. You need to make sure your Listener is running before you can connect. At a command prompt:
    > LSNRCTL
    > status
    If you receive an error, start the listener:
    > start