Robot Framework show IP addresses

Recently I was struggling with an error message caused by the not opened firewall between Robot executing computer and the server hosting the website.

"WebDriverException: Message: unknown error: net::ERR_CONNECTION_TIMED_OUT"

So the straightforward solution is to fetch the public and/or private IP address of the machine hosting robot tests to do a proper firewall opening on port 80/443.

You can do it by following block which will print output to the console.

*** Settings ***

Library Selenium2Library

Library String

*** Variables ***

${BROWSER} edge

*** Test Cases ***

Network scanning

[Documentation] Print network details of test execution machine

${ip}= Evaluate [l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1], [[(s.connect(('', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) if l][0][0] socket

Log To Console Private IP is: ${ip}

Open Browser http://api.hostip.info/get_json.php ${BROWSER}

${ippublic}= Get Text //html/body/pre #get the IP address text

Log To Console Public networking details are: ${ippublic}

Close Browser

If it's hard to read, use this GitHub Gist with the same code. And that is all what was needed to do.

Here is how the output is looking like:

Žádné komentáře :


Dotaz, připomínka, oprava?
(pokud máte problém s vložením příspěvku, vyzkoušejte to v prohlížeči Chrome)