首页 > 解决方案 > 当我们使用 java (jython) 通过 bat 脚本为机器人项目运行机器人文件时出现导入错误

问题描述

我们使用 Jython 使用 java 创建了机器人框架,如下所示。

项目结构

当我们从 Eclipse IDE 执行它时,它工作正常。

我们将把它配置到 Jenkins 中,我们已经为构建和测试创建了下面的批处理脚本

建造:

call mvn clean
call mvn assembly:assembly -DdescriptorId=jar-with-dependencies
build is created successfully

测试:

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

当我们触发此脚本时,我们收到以下错误:

C:\Users\k64066262\rep\KTOC-TRB-Automation>test.bat >>status.txt
[ 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

错误信息

错误信息 :

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 
==============================================================================
RegressionTest France                                                         
==============================================================================
Verify Tender Created Successfully                                    | FAIL |
Parent suite setup failed:
No keyword with name 'Launch Browser' found.

标签: batch-filejenkinsrobotframeworkpython-importjython

解决方案


推荐阅读