I am trying to run test cases on both browser & mobile sequentially , so when my mobile test cases are triggered. I am trying to change webdriver.driver property during runtime, by using
environmentvariables.setproperty("webdriver","appium"). But this is ignored and tests try to run on chrome browser which is already set in serenity.prop file
My question is :Can I change the serenity.prop values during runtime , if yes? then how?
and what is the significance of environmentvariables.setproperty("webdriver","appium") ?
No: environment variables are immutable, they are not meant to be changed this way. You can run a single test using multiple browsers using Screenplay.
@wakaleo why it's not possible to change them?
I have a scenario in which it make sense to change environment variables:
I want to change the app source for some scenarios (updating older app to new one) in my suite so it would be matter of changing env variable in code in some test scenarios.. I don't want to run those scenarios in separate runs as I want single report and single run.. If I would initialize AppiumDriver manually, I would just change desired capabilities for those scenarios before initializing driver. But when I left the initialization to serenity I have no way to change these, because I cannot change that env variable appium.app as it is ummutable.
It would be useful to be able to override this. We have user stories where application behavior changes based on the browser the user is in. For example popping up a modal if the user is in IE. If browser is specified in the Scenario, we should be able to set the webdriver property in a scenario step, otherwise there's no guarantee the Scenario is running with the correct webdriver.
+1, my tests are starting up docker containers which I dont know the port it gets assigned at runtime.
In my project, I am looking for to set one property(manual like one global variable) which value I want to set in run time also should be override that property. Will it possible?
I have set property and I am able to call in my program also, but able to change it in runtime.
Just use a threadlocal variable. Environment variables are shared by all tests and therefore are immutable by design.
Ok. Thanks for instant reply.
Most helpful comment
@wakaleo why it's not possible to change them?
I have a scenario in which it make sense to change environment variables:
I want to change the app source for some scenarios (updating older app to new one) in my suite so it would be matter of changing env variable in code in some test scenarios.. I don't want to run those scenarios in separate runs as I want single report and single run.. If I would initialize AppiumDriver manually, I would just change desired capabilities for those scenarios before initializing driver. But when I left the initialization to serenity I have no way to change these, because I cannot change that env variable
appium.appas it is ummutable.