How to log the version of RF in my test?

Hello,

Do you know how can I log to the console the version of selected installed libraries (or other elements) ?
For example, I would like to log the version of RF inside of my test.

Thanks a lot.

John.

Hi John,

As far as I know, there is nothing builtin to do what you are after, this should do what you want though:

*** Settings ***
Library		Process
Library		String
Library		Collections

*** Test Cases ***
Simple example
	${packgs} =    Run Process    pip		list
	Log		${packgs.stdout}
	Should Contain		${packgs.stdout}		robotframework-seleniumlibrary

Dictionary example
	&{packages}= 	Get Packages
	Log		${packages}
	Dictionary Should Contain Key		${packages}		robotframework-seleniumlibrary
	Log		${packages['robotframework-seleniumlibrary']}

*** Keywords ***
Get Packages
	&{packages} =	Create Dictionary
	${pkgs} =   	Run Process		pip		list
	@{lines}=		Split To Lines		${pkgs.stdout}
	FOR    ${line}    IN    @{lines}
		@{words}=		Split String		${line}
		IF	'${words[0]}' == 'Package'
			Log		Package
		ELSE IF		'${words[0][0:3]}' == '---'
			Log		---
		ELSE
			Set To Dictionary		${packages}		${words[0]}		${words[1]}
		END
	END
	[return] 	&{packages}

I kept it all in RF keywords for you.

Dave.

Hello Dave,

I didn’t expected this kind of response :slight_smile: => Very complete and fast !

Thanks a lot ! I could’nt imagine that is would be so “complex” to have this kind of information.

I wrote this before your answser :

${version}=    Evaluate    robot.__version__
Log To Console    La version de RF utilisée est ${version}

Is it wrong ?

John

Hi John,

No it’s not “wrong”, but you might find it’s limited to just giving you the version of robot framework and not all the libraries you might also want the version numbers for.

There is an old saying “give 100 programmers the same problem and you’ll get 100 different right answers” the point being there is usually many ways to solve a problem, the best way is the way that gives you the answers you need and is easy for you to understand. I gave you a solution not “the” solution :grinning:

Dave.

Hi John,
My two cents:
I think you’re trying to answer the the question “Which testware version am I using?”. Instead, I think you should solve this the other way around: Which version of testware will I install? There are multiple options to pin your testware. You could use a requirement.txt file, or more sophisticated, use something like Poetry for dependency management. This way, you know what’s installed, and therefore you’re able to serve this information from the source where you’ll install it from.

Hope this helps solving the question behind your question :slight_smile:

Thanks for all your reply !

I have now differents tools :slight_smile:

John

1 Like