0
votes

I can not figure out how to import and/or use a python package. I really need some help getting off the ground with this. I want to accomplish getting 1 smoke test working. I'm now working in Windows 10 1809 os.

I've set up Eclipse to use Robotframework and RED robot. I have a project created with a folder, suite, and working test case (which does not include any Python). I've tried importing our "GoDirect" package, but when running the test shows that library has warning about no keywords. So, I'm assuming I have to create an external python.py file, and I tried to get one working but could not figure out how to set that up in the Eclipse Environment and use it.

My goal is to get a test case working that connects to a sensor, and reads information from it. I currently have no results other than a working skeleton test case. I'm new to Eclipse, but have "some" experience working with RobotFramework in the SikuliX IDE for a different application (using Mac Mojave).

This is my working Test case:

*** Settings ***   

Suite Setup       
Log    I am inside Test Suite Setup

Suite Teardown   
Log    I am inside Test suite Teardown

Test Setup       
Log    I am inside Test Setup

Test Teardown     
Log    I am insied Test Teardown   

Default Tags        sanity    

*** Test Cases ***

gdx_smoke_test

    [Tags]    smoke
    Log    Hello World...


*** Variables ***


*** Keywords ***

Below is a "pip list" of what I have installed on my Windows 10 1809 os:

Package Version


enum-compat 0.0.2
godirect 1.0.3
hidapi 0.7.99.post21 pexpect 4.7.0
pip 19.1.1
ptyprocess 0.6.0
pyserial 3.4
robotframework 3.1.1
robotframework-selenium2library 3.0.0
robotframework-seleniumlibrary 3.3.1
selenium 3.141.0
setuptools 41.0.1
urllib3 1.25.3
vernierpygatt 3.2.0
wheel 0.33.4

Below is the website we use for students and teachers to download and use our "godirect" python implementations

https://www.vernier.com/engineering/python/

05/30/2019 : I'm working on an external python file that creates a class object with a few "def" functions in it. I'm thinking I can put that .py someplace in the Eclipse project folder and import it (as a library) into RobotFramework. In theory I should be able to call Keywords into that .py class object. Example of the possible .py:

05/31/2019 : OK guys. I solved it on my own. I mislead myself a lot on our website. There was a few things I ended up doing to solve it. I'll explain below for anyone that's interested.

1) Copied gdx.py to site folder: It turns out I can't just do "pip install godirect[usb,ble]" alone. This only installs the site package in a folder that the Robotframework and RED.xml will use. I needed to also download one of their files that had a "gdx.py" file in it. That file has keywords in it such as "open_usb(self)" and many other ones. So I copied that "gdx.py" file to the site folder.

2) Add gdx.py to RED.xml : Double clicked the RED.xml which opens the RED project Referenced Libraries window. and added the gdx.py Library.

3) Added the "Library gdx" in the Settings of Robot Framework

4) Added keyword "open usb": In my gdx_smoke_test I added this keyword to it

5) Ran the test suite and it passed!

The passing smoke test for using a custom Python file is below (shows changes I made to the original above)

*** Settings ***   
Library  gdx                       
Suite Setup       
Log    I am inside Test Suite Setup

Suite Teardown   
Log    I am inside Test suite Teardown

Test Setup       
Log    I am inside Test Setup

Test Teardown     
Log    I am insied Test Teardown   

Default Tags        sanity    

*** Test Cases ***

gdx_smoke_test

    [Tags]    smoke
    Log    Hello World...
    open . usb


*** Variables ***


*** Keywords ***
1
Our site shows to use, you would do this: from gdx import gdx gdx = gdx.gdx(). I've gotten this to connect to the GoDirect hardware and collect data, but it was all done outside the context of the IDE (robotframework). - Mel Raymond
What library are you trying to import? Is it written by you? - Sameem
Why do you think that your package is not imported? I've tried importing but when running the test shows that library has warning about no keywords. doesn't really sound like an import error. A typical module import error goes like ImportError: No module named foo - kerwei
This code has several problems and is not a working test case. Have you read through the user guide? It has some very clear examples of how to create your own keyword libraries which can use any other modules you want. - Bryan Oakley
Sameem: We have a GoDirect package that teachers and students can use to create Python scripts to connect our Go Direct Sensors. It's the "godirect" Library. - Mel Raymond

1 Answers

0
votes

OK, solved it myself. I made changes to the original post showing what I did to solve it.