Skip to main content

How to Avoid Hard coding of Paths in QTP Tests

We should avoid hard coding of paths in tests as this adds to portability of test from one machine other.
Consider an action having following statement –
Execute File (D:\GSB\QTP\fucntion\test.vbs)
When tests are ported on a different machine then there is no guaranteed about drive mapping being same.
To over come this, we can read path run time instead of hard coding it; as following -



Make sure assignment of Global is first action as only then Run Time Env file would be available for usage.

THanks,
Tarun K

Comments

  1. FYI: You can use Environment("varname"), you don't need the ".Value".
    Good work otherwise!

    ReplyDelete
  2. How can we follow same practice in Selenium Automation Project?
    Example: System.setProperty("webdriver.chrome.driver",
    "D:/automation/myproject/src/chromedrivers/win7/chromedriver_2.exe"); or in pom.xml

    C:/Users/OfficePC21/workspace/deletexslt/testxslt/testng.xml

    ReplyDelete

Post a Comment

No spam only genuine comments :)