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 :)

Popular posts from this blog

Verify email confirmation using Selenium

Note: If you are new to java and selenium then start with selenium java training videos .     Email confirmation seems to be integral part of any registration process. I came across an application which lets you provide your email address. You can follow the sign up link in you mail and then complete the registration process. Lets consider we provide GMail address for it. Now if were to use only Selenium then we would have to follow following steps - Launch GMail using Selenium; Some how search for new mail in the list of available mails; Some how click on it; Parse the mail message; Get the registration link; Follow up with registration process What do you think of an approach in which you can

Capture network traffic using WebDriver

We often come across testing requirements when we need to analyze the network traffic to find - HTTP status of page Analyze header information to find if right information is passed Validating parameters related to ajax requests etc Selenium 1 has had a way to capture n/w traffic but the feature does not always work as expected. At times Selenium 1 does not capture all n/w traffic, And given that Selenium 1 APIs are almost dead it is

Selenium Tutorial: Get attribute of an element

With Selenium 1.0 Let us consider Google Search Box for example and its "max length"is to be retrieved. Using xPath -         String var = selenium.getAttribute("//input[@name='q']/@maxlength");         System.out.println(var); Using css locator -                        String var = selenium.getAttribute("css=input[name='q']@maxlength");         System.out.println(var);        With Selenium 2.0 (WebDriver)        Using xPath -         String var = webDriver.findElement(By.xpath("//input[@name='q']")).getAttribute("maxlength")         System.out.println(var); Using css locator -                     ...