How to run scenarios in different browsers?

Comments

3 comments

  • Avatar
    Mansi Shah

    Hi Alexey,


    This can be achieved by doing the following:


    1. If you want to have multiple browser options, copy the twist.properties file and rename them as follows:


    firefox.twist.properties


    chrome.twist.properties


    (Make sure to edit the properties file to reflect the appropriate browser)


    2. Create a system variable called say, launch_browser in Preferences->Twist-> Default JVM arguments for launching


    -Dlaunch_browser=chrome


    (If you want Chrome to be used to run the tests)


    3. Make the following changes in the applicationContext-suite.xml


    <bean class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
    <property name=”systemPropertiesModeName” value=”SYSTEM_PROPERTIES_MODE_OVERRIDE”/>
    <property name=”ignoreResourceNotFound” value=”true”/>
    <property name=”locations”>
    <list>
    <value>classpath:twist.properties</value>
    <value>classpath:${launch_browser}.twist.properties</value>
    </list>
    </property>
    </bean>


    This way when you run your tests, Twist will use the browser that is specified as a system variable(in step 2).


    4. If you have exported the twist project (or used 'Export Twist Libraries' option), Twist would generate an ant build file containing <twist.runner> task.
    <twist.runner scenarioDir="${twist.project.dir}/scenarios"
                          reportsDir="${twist.reports.output.dir}"
                          confDir="${twist.config.dir}"
                          failureproperty="twist.scenarios.failed"
                          classpathref="scenarios.classpath"
                          tags="!in-progress" threads="1"
                          jvmargs="-Dlaunch_browser=${launch_browser}"/>


    5. Now from command prompt, you can specify which launch_browser to use, using -D option:


    ant -buildfile build.xml execute-scenarios -Dlaunch_browser=chrome
    or
    ant -buildfile build.xml execute-scenarios -Dlaunch_browser=firefox


    Hope this helps!


    Thanks!


    Mansi

    0
    Comment actions Permalink
  • Avatar
    Alexey Litosh

    Yes! Thank you! It's working! :)


    Except step #2 - when I add '-Dlaunch_browser=browser_name' to JVM arguments it has no effect. Instead twist launches browser which is set in system variable. So if I want to change browser I have to change the system variable value manually (or using bat-file) and then restart twist.


    Hope, it's posible to start different test-suits on different browsers via Maven using some script to change sys variable value.

    0
    Comment actions Permalink
  • Avatar
    Angshuman

    Hi Alexey,


    Yes, if you would do it from ant/maven/command prompt, it would immediately take effect. for the other issue, one possible reason is that the "run configurations" may still have the old settings. See the post on "managing multi env config" - http://community.thoughtworks.com/posts/5aa8df9df4.


    thanks

    0
    Comment actions Permalink

Please sign in to leave a comment.