How to add environment variable(with Key and Value pair) run time in keyword Driven Framework | Selenium Python Forum
A
Arvind C Posted on 08/12/2020

How to add environment variable(with Key and Value pair) run time in keyword Driven Framework


0
09914040666 Replied on 08/12/2020

Hey, 

You can add environment variable(with Key and Value pair) using the 'os' module in python. Like this:

os.environ['KEY'] = 'VALUE'


A
Arvind C Replied on 08/12/2020

Can I Use same code even to add a Environment Variables in my Keywor Driven Framework during the run time


0
09914040666 Replied on 08/12/2020

Yes.


M
Replied on 08/12/2020

Thanks for the response

On executing below line of code with varcount being dynamic value. I am getting error "SyntaxError: invalid syntax (<string>, line 1)" error. Unable to get to know the exact issue. Can you please help me in unblocking.

os.environ['Projectname'] = '/html/body/div[1]/div[1]/div/table/tbody/tr[1]/td['+varcount+']/a'


A
Arvind C Replied on 08/12/2020

I am able to add the dictionary successfully after adding the same in the try catch block.

But the 'Projectname' key and its Value is not added to environment variables of the project framework.


0
09914040666 Replied on 08/12/2020

Please let me know the requirement of 'ProjectName' to be added in environment variable and kindly send the snippet for the code so that I can check.


Related Posts