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

    Wednesday, March 17, 2010

    Quality Center - Copying from one project to another

    It always feels weird having two instances of Quality Center open in order to copy and paste tests from one project to another. But that's how QC rolls!

    I had two projects with the same custom "user fields" on the "test" entity. But every time I copied and pasted tests from one project to another, the values in these fields pasted all jumbled up. That's because the fields need to have the same "Field Name" (ex: TS_USER_04). My fields had the same field label, but they needed to have the same field name. Ya know, that magical name automatically assigned by QC.


    Saturday, March 13, 2010

    Locating Pop-Up Windows in Selenium IDE

    Here's a good article about handling pop-up windows. This is for pop-up browser windows, not modal windows.

    Basically, you have to '''selectWindow''' to select the popup window and execute commands on that window. To return to the main window, use the command '''selectWindow(null)'''. This command only works if the browser only has one tab open (which will be the main window's tab). If multiple tabs are open in the browser, Selenium will error.

    Javascript for creating random numbers in Selenese

    I use these javascript snippets in Selenese to generate random numbers in a Selenium IDE script. This is helpful when a value has to be unique.

    Here's an example using javascript to get the current timestamp and use that value for the variable ("codigo" in this example):

    storeEval
    new Date()
    today

    storeEval
    storedVars['today'].getTime()
    codigo

    type
    bsa.olbServiceId
    ${codigo}

    echo
    Codigo is ${codigo} for WOV Everything

    Below, I needed to generate random usernames that were 6-20 characters with letters and numbers. I used Javascript to get the current timestamp, converted it to a string, then contatenated with 'usr':

    storeEval
    new Date()
    today

    storeEval
    storedVars['today'].getTime()
    numtime

    storeEval
    storedVars['numtime'].toString()
    time

    storeEval
    ['usr']+storedVars['time']
    username

    echo
    ${username} is the username.

    More info on Javascript and Selenese is in the Selenium documentation.

    Helpful Firefox Add-On's when using Selenium IDE

    The following Firefox Add-on's will help you use Selenium, particularly when it comes to XPath Locators:

    * XPath Checker - suggests XPath and can be used to test the XPath you write.
    * Firebug - XPath suggestions are just one of the many powerful features of this very useful add-on. You can inspect elements to view the HTML code for that element.

    Quality Center Microsoft Word Add-In Tips

    I'm using the QC Microsoft Word Add-In for the first time and learning all of it's quirks. I'm importing Requirements into QC. Or as QC likes to say, "exporting".

    It seems to want me to rename the Requirement Types in my project before it will recognize the Type during "export".

    For example, upon export, I kept getting the error:
    "Requirement Type 'Business' does not exist in the requirement type lookup list."

    I had the requirement type "Business", which I think is a default type. In Project Customizations, I had to rename "Business" to "Business Requirement". Then Import the requirement types using the Word QC Macro. Then I could successfully export the requirements without getting that error.

    Then later I was getting the same error with other requirement types. I found that if I imported the requirement types from my project right before exporting to QC, the errors went away.

    Very strange. I'm on Windows 7 with Office 2007 and an outdated QC version; so maybe that's why.