robotframework / SeleniumLibrary

Web testing library for Robot Framework
Apache License 2.0
1.39k stars 765 forks source link

Python and SeleniumLibrary installed but still receiving ImportError: No module named SeleniumLibrary #1615

Closed guillermolam closed 4 years ago

guillermolam commented 4 years ago

Python as well as SeleniumLibrary are installed as evidenced by pip list ran by Jenkins inside the container

Pip List

Package                        Version
------------------------------ ---------
appdirs                        1.4.4
backports.functools-lru-cache  1.6.1
backports.ssl-match-hostname   3.5.0.1
beautifulsoup4                 4.9.1
certifi                        2020.6.20
chardet                        3.0.4
decorator                      3.4.0
ethtool                        0.8
idna                           2.10
iniparse                       0.4
ipaddress                      1.0.16
javapackages                   1.0.0
kitchen                        1.1.1
lxml                           3.2.1
pip                            20.2b1
pycurl                         7.19.0
pygobject                      3.22.0
pygpgme                        0.3
pyinotify                      0.9.4
pyliblzma                      0.5.3
python-dateutil                1.5
python-dmidecode               3.10.13
pyxattr                        0.5.1
requests                       2.24.0
robotframework                 3.2.1
robotframework-seleniumlibrary 4.4.0
selenium                       3.141.0
setuptools                     44.1.1
six                            1.9.0
soupsieve                      1.9.6
subscription-manager           1.21.10
tqdm                           4.47.0
urlgrabber                     3.10
urllib3                        1.25.9
webdrivermanager               0.8.0
yum-metadata-parser            1.1.4

Environment

Operating System: RHEL 7 Jenkins Slave running in Docker Container as a part of an Openshift 3.11 platform

Running Command

robot --variable USERNAME:**** --variable PASSWORD:**** --variable ENVINMT:CERT --variable API_NAME:customer-api-services --variable API_VERSION:null --variable ASSET_VERSION:5.0.2 --variable LIST_OF_POLICIES:logging-init-policy-v1.0.4 --variable JIRA_TICKET:SAPIM-52 tasks/publish-api-mule.robot

Error messages and additional information

[ ERROR ] Error in file '/tmp/workspace/test-1_master/tasks/resource.robot' on line 7: Importing test library 'SeleniumLibrary' failed: ImportError: No module named SeleniumLibrary
Traceback (most recent call last):
  None
PYTHONPATH:
  /usr/local/bin
  /usr/local/lib/python2.7/site-packages/setuptools-7.0-py2.7.egg
  /usr/local/lib/python2.7/site-packages/robotframework-3.2.2.dev1-py2.7.egg
  /usr/local/lib/python27.zip
  /usr/local/lib/python2.7
  /usr/local/lib/python2.7/plat-linux2
  /usr/local/lib/python2.7/lib-tk
  /usr/local/lib/python2.7/lib-old
  /usr/local/lib/python2.7/lib-dynload
  /home/jenkins/.local/lib/python2.7/site-packages
  /usr/local/lib/python2.7/site-packages
==============================================================================
Publish-Api-Mule :: Publish an API in Anypoint API Manager                    
==============================================================================
Publish API in Anypoint Manager                                       | FAIL |
No keyword with name 'Open Browser' found.

Also teardown failed:
No keyword with name 'Close Browser' found.
------------------------------------------------------------------------------
Publish-Api-Mule :: Publish an API in Anypoint API Manager            | FAIL |
1 critical task, 0 passed, 1 failed
1 task total, 0 passed, 1 failed
==============================================================================
Output:  /tmp/workspace/test-1_master/output.xml
Log:     /tmp/workspace/test-1_master/log.html
Report:  /tmp/workspace/test-1_master/report.html
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

Resource.robot

*** Settings ***
Documentation     A resource file with reusable keywords and variables.
...
...               The system specific keywords created here form our own
...               domain specific language. They utilize keywords provided
...               by the imported SeleniumLibrary.
Library           SeleniumLibrary
Library           String

*** Variables ***
@{POLICIES}                 []
${SERVER}                   anypoint.mulesoft.com
${BROWSER}                  Chrome
${DELAY}                    0
${LOGIN URL}                https://${SERVER}/login
${JIRA_API_ID}              -
${JIRA_AUTODISCOVERY_HASH}  -
${API_ID}                   -
${AUTODISCOVERY_HASH}       -

*** Keywords ***
Open Browser To Login Page
    Open Browser    ${LOGIN URL}    ${BROWSER}
    Maximize Browser Window
    Set Selenium Speed    ${DELAY}
    Login Page Should Be Open

Login Page Should Be Open
    Title Should Be    Anypoint Platform

Go To Login Page
    Go To    ${LOGIN URL}
    Login Page Should Be Open

Input Username
    [Arguments]    ${USERNAME}
    Input Text  //*[@id="appRoot"]/main/div/div/div/div[1]/form/div[1]/div/div/input    ${USERNAME}

Input Password
    [Arguments]    ${PASSWORD}
    Input Text  password    ${PASSWORD}

Submit Credentials
    Click Element    //*[@id="appRoot"]/main/div/div/div/div[1]/form/button

Welcome Page Should Be Open
    Title Should Be    Anypoint Platform

CLick on API Manager
    Wait Until Element Is Enabled     //*[@id="appRoot"]/div/div/section[1]/div/div[2]/div/ol/li[2]/a/div/span[1]
    Click Element    //*[@id="appRoot"]/div/div/section[1]/div/div[2]/div/ol/li[2]/a/div/span[1]

Select Environment
    [Arguments]     ${ENVIRONMENT}
    Wait Until Element Is Enabled     //div[contains(text(),'${ENVIRONMENT}')]
    Click Element    //div[contains(text(),'${ENVIRONMENT}')]

Click on Manage from API Exchange
    Wait Until Element Is Enabled     //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/div[2]/div[1]/div[1]/button/div[2]
    Click Element       //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/div[2]/div[1]/div[1]/button/div[2]
    Wait Until Element Is Enabled   //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/div[2]/div[1]/div[1]/ul/li[1]/a
    Click Element    //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/div[2]/div[1]/div[1]/ul/li[1]/a

Input API to Deploy and Save
    [Arguments]    ${API NAME}
    Set Focus To Element        //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[1]/div/div/div
    Wait Until Element Is Enabled   //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[1]/div/div/div
    Input Text  //*[@id="react-select-2--value"]/div[2]/input      ${API NAME}
    Sleep   2s
    Mouse Down  //*[contains(text(), "${API NAME}")]
    Press Keys  xpath=//body    TAB

Select API Version
    [Arguments]     ${API VERSION}
    Wait Until Element Is Enabled   //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[3]/div/div/div
    Click Element   //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[3]/div/div/div
    Wait Until Element Is Enabled       //*[contains(text(),'${API VERSION}')]
    Click Element        //*[contains(text(),'${API VERSION}')]

Select Asset Version
    [Arguments]     ${ASSET VERSION}
    Wait Until Element Is Enabled       //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[4]/div/div/div/div/span[2]/span
    Click Element       //*[@id="am-get-from-exchange-container"]/div/form/div[1]/div[4]/div/div/div/div/span[2]/span
    Wait Until Element Is Enabled       //*[contains(text(),'${ASSET VERSION}')]
    Click Element        //*[contains(text(),'${ASSET VERSION}')]

Save and Publish API
    Click Element    //*[@id="save-button"]/span
    Wait Until Element Is Enabled   //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/ap-api-version-header/div[1]/div/div[1]/div/div[1]/span

Copy API ID and Autodiscovery hash
    ${API_ID}=  Get Text    //*[@id="contentWrapper"]/ui-view/ui-view/div/div/div/ap-api-version-header/div[1]/div/div[2]/div[2]/div[1]/span[2]
    Set Suite Variable  ${JIRA_API_ID}  ${API_ID}
    Wait Until Element is Enabled   //*[@id="autodicovery-props"]/span/div/button
    ${AUTODISCOVERY_HASH}=  Get Element Attribute   //*[@id="autodicovery-props"]/span/div/button   attribute=data-clipboard-text
    Set Suite Variable  ${JIRA_AUTODISCOVERY_HASH}  ${AUTODISCOVERY_HASH}

Apply Policy
    [Arguments]     ${POLICY_NAME}
    Wait Until Element is Enabled       //*[@id="contentWrapper"]/div/ap-left-sidebar/div/ul[2]/li[3]/a
    Click Element   //*[@id="contentWrapper"]/div/ap-left-sidebar/div/ul[2]/li[3]/a
    Wait Until Element is Enabled   //*[@id="contentWrapper"]/ui-view/ui-view/div/div/ui-view/div/div[3]/div/div[1]/button
    Click Element   //*[@id="contentWrapper"]/ui-view/ui-view/div/div/ui-view/div/div[3]/div/div[1]/button
    Wait Until Element is Enabled   //*[@class="modal-body ap-resource-level-policies ng-scope"]
    ${for_value}=   Get Element Attribute      //label[@title="${POLICY_NAME}"]      for
    Execute Javascript      document.getElementById("${for_value}").click()
    Wait Until Element is Enabled  //button[contains(text(), "Configure Policy")]
    Click Element   //button[contains(text(), "Configure Policy")]
    Wait Until Element is Enabled  //*[@id="contentWrapper"]/ui-view/div/div/div[1]/form
    Click Element   //*[@id="contentWrapper"]/ui-view/div/div/div[1]/form/div[3]/button[2]

Apply Policies
    [Arguments]     ${ALL_POLICIES_COMMA_SEPARATED}
    @{POLICIES}=    Split String       ${ALL_POLICIES_COMMA_SEPARATED}     ,${SPACE} 
    FOR    ${POLICY}    IN    @{POLICIES}
        Apply Policy  ${POLICY}
    END

Share Details in JIRA via Comment
    [Arguments]     ${JIRA NUMBER}
    Go to   https://jira-sdop.us.corp/browse/${JIRA NUMBER}
    Wait Until Element is Enabled   //*[@id="dprAdapters"]
    Select From List By Index   //*[@id="dprAdapters"]  3
    Submit Form
    Wait Until Element is Enabled   footer-comment-button
    Click Element   footer-comment-button
    Wait Until Element Is Enabled   //*[@id="comment"]
    Sleep   1s
    Input Text  //*[@id="comment"]      ${JIRA_API_ID} \n\n ${JIRA_AUTODISCOVERY_HASH}
    Click Element   //*[@id="issue-comment-add-submit"]
aaltat commented 4 years ago

The error message indicates that RF/Python import system does find SeleniumLibrary installation from the Python environment you are using to run your tests. Please install SeleniumLibrary to the Python environment you are using to run your tests. For further support, see https://github.com/robotframework/SeleniumLibrary#support

guillermolam commented 4 years ago

The error message indicates that RF/Python import system does find SeleniumLibrary installation from the Python environment you are using to run your tests. Please install SeleniumLibrary to the Python environment you are using to run your tests. For further support, see https://github.com/robotframework/SeleniumLibrary#support

If it does find the library, why does it throw this error: "No module named SeleniumLibrary" Python is in fact installed as well as SeleniumLibrary as evidenced by pip list ran by Jenkins inside the container

guillermolam commented 4 years ago

@aaltat Please reopen this issue