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:
Our code is put in Git Repository
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,
- 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.
2. This TRB jar file is mapped/configured under Red.xml Java Path/Libraries for the .robot file named ‘RegressionTest-France.robot’
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
- Created pom.xml with all dependencies, Below image shows the packaging information
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
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