How to pass parameter to ant scripts?

前端 未结 2 1389
忘了有多久
忘了有多久 2021-02-20 17:19

Recently I am working on selenium webdriver 2.0 (developing automation framework). As per requirement for every faiulre the screenshot must be capture (file path and filename: .

2条回答
  •  北海茫月
    2021-02-20 18:01

    Using Java System Property

    You can pass a variable as a JVM argument. Assuming you have a variable named "screenShotRoot" defined like this

    ant -DscreenShotRoot=/screenshots/testcases
    

    you can read it in your build.xml like this

    
    

    Your ANT task can then use this root path to generate appropriate paths to your PNG files on the date expected.

    See this Apache ANT FAQ page

    Using Environment Variables

    You can also use Operating System environment variables, by setting them before calling your script. Assuming you have an environment variable named "screenShotRoot" defined like this on Windows

    SET screenShotRoot=/screenshots/testcases
    

    you can read it in your build.xml like this

    
    
    

    Using Properties Files

    You could also write your links into a properties file that your ANT script loads, like this

    
    

提交回复
热议问题