2

This is the first time We are trying to execute the robot framework code(Red.xml) using Shell script. Need this script execute in Jenkins but before which we tried to execute in local system whether the script that we have written is correct. Unknown that how the script calls the jar files of our exported java code. Basically the script is finding difficulty to read the KTOC folder where the java code is maintained.

The below is the error I received when executing the script.

[ ERROR ] Error in file 'C:\Users\k64066262\rep\KTOC-TRB-Automation\KTOC_TRB_TestAutomation\TestSuites\RegressionTest_France.robot': Importing test library 'com.KTOC.TRB.testautomation.Keywords.Keywords' failed: ImportError: No module named KTOC

RegressionTest France                                                         
==============================================================================
Verify Tender Created Successfully                                    | FAIL |
Parent suite setup failed:
No keyword with name 'Launch Browser' found.

Robot File has the below settings in it.

*** Settings ***
Library    com.KTOC.TRB.testautomation.Keywords.Keywords
Resource   ../ResourceFiles/TRB_Keywords.txt
Variables  ../FrontlinesTRB/TRB-env.py
Variables  ../FrontlinesTRB/France.py
Suite Setup    Launch Browser  ${OperatingSystem}
Suite Teardown    Close Browser

Below is the script that we tried to execute,

C:\Users\k64066262\rep\KTOC-TRB-Automation>java -cp target\KTOC-TRB-automation-1.0-SNAPSHOT-jar-with-dependencies.jar;robotframework-3.0.2.jar -Dwebdriver.chrome.driver=chromedrivers\chromedriver.exe -Dheadless=false org.robotframework.RobotFramework --variablefile KTOC_TRB_TestAutomation\FrontlinesTRB\France.py --variablefile KTOC_TRB_TestAutomation\FrontlinesTRB\TRB-env.py KTOC_TRB_TestAutomation\TestSuites\RegressionTest_France.robot

We are still unclear on the script that we actually copied from some other post and tried to execute. This is the section of our script java -cp target\KTOC-TRB-automation-1.0-SNAPSHOT-jar-with-dependencies.jar;robotframework-3.0.2.jar - quite confusing.

We have exported all our java code related to this execution into a jar named "TRB.jar". How does the script access the jar file? Where in my script i should specify the jar "TRB.jar" so that system can use my code about the keyword Launch Browser

Note:

  1. Our code is put in Git Repository

  2. We are trying to execute the script from a common server but not from local system

Below are the links i went through for fixing up my code, but was not helpful as our scripting is specific to Red.xml.

Continuous Integration with Jenkins - clarifications

Jenkins Error: Powershell Integration with Jenkins

GitHub integration with Jenkins

Reproducible Steps:

Let me give a simple reproducible steps for executing the .bat script in local system,

  1. Developed Java files of keywords and exported as TRB.jar For e.g. created keyword "Launch Browser". This keyword has been called under 'Settings' section in robot file. enter image description here

enter image description here 2. This TRB jar file is mapped/configured under Red.xml Java Path/Libraries for the .robot file named ‘RegressionTest-France.robot’ enter image description here 3. Mapped the external jars like Selenium-java, Selenium-Server-Standalone, robot framework-selenium2Library-java under Classpath Note: We are able to successfully execute the .robot file when executing via eclipse

Below steps have been followed to execute the same .robot file using .bat script

  1. Created pom.xml with all dependencies, Below image shows the packaging information enter image description here
  2. Created a .bat file to build the code named ‘Build.bat’ Below is the script that we used inside the bat file, the build was successful and created a jar file named target

    call mvn clean call mvn assembly:assembly -DdescriptorId=jar-with-dependencies

  3. Created a .bat file(named ‘test.bat’) to execute the ‘RegressionTest-France.robot’ wherein the below script has been used.

java -cp target\nemo-test-automation-1.0-SNAPSHOT-jar-with-dependencies.jar;robotframework-3.0.2.jar -Dwebdriver.chrome.driver=chromedrivers\chromedriver.exe -Dheadless=false org.robotframework.RobotFramework --log logs/FranceLog.html --report Reports/FranceReport.html --output outputs/France.xml --exitonfailure --variablefile KTOC_TRB_TestAutomation\FrontlinesTRB\France.py --variablefile KTOC_TRB_TestAutomation\FrontlinesTRB\TRB-env.py  KTOC_TRB_TestAutomation\TestSuites\RegressionTest_France.robot

This script is what throwing the module import error. Unsure how this script calls the TRB.jar file.

For more details, you can access the code in this link

Roja
  • 293
  • 1
  • 5
  • 21
  • 1
    At the core of your issue is a Jar file with unknown contents. From the description it is unclear when the Jar file works as expected, if it works at all. Much of these issues can be cleared up by creating a [mcve]. In your case an example Jar file with 1 keyword that you call from a single robot test script. If you can reproduce the error in this setup it will be easier for others to replicate the issue and help you. – A. Kootstra Feb 10 '20 at 14:24
  • 1
    The error means that the KTOC module doesn't exist in the python environment running on the agent. I don't know if you're using a virtualenv or install modules globally on your agent, but the KTOC module will have to be installed there. – Mzzl Feb 10 '20 at 17:08
  • @Kootstra - Thanks for your response. I have edited the question with reproducible steps titled ***Reproducible Steps:*** Also the link to access the files given. – Roja Feb 11 '20 at 07:07
  • @Mzzl - Thanks for your response. Even in the local system which has all the files setup, we are unable to succeed it. Provided ***Reproducible Steps:*** in my question for your reference to look for our mistake done. – Roja Feb 11 '20 at 07:10
  • Although it is obvious that you're committed to solving this issue by adding more information to this question. However, adding **more** information is counterproductive to your goal: finding a solution. Bring it back to a single robot file with a single java class. I don't see many people taking on the challenge you have presented here. – A. Kootstra Feb 12 '20 at 19:56

0 Answers0