首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Oracle OpenScript在替换变量时“读取文件时出错”

Oracle OpenScript在替换变量时“读取文件时出错”
EN

Stack Overflow用户
提问于 2017-08-08 16:00:31
回答 2查看 615关注 0票数 1

我正在用Oracle OpenScript编写一个网页脚本。

我记录了要执行的操作

  • open link
  • select下拉菜单
  • select字段从下拉列表中选择

现在,我尝试用我在assets中创建的.csv中的变量替换要打开的链接,但我收到了一条“错误读取文件”的消息。

下面是完整的代码:

代码语言:javascript
复制
import oracle.oats.scripting.modules.basic.api.*;
import oracle.oats.scripting.modules.browser.api.*;
import oracle.oats.scripting.modules.functionalTest.api.*;
import oracle.oats.scripting.modules.utilities.api.*;
import oracle.oats.scripting.modules.utilities.api.sql.*;
import oracle.oats.scripting.modules.utilities.api.xml.*;
import oracle.oats.scripting.modules.utilities.api.file.*;
import oracle.oats.scripting.modules.webdom.api.*;

public class script extends IteratingVUserScript {
@ScriptService oracle.oats.scripting.modules.utilities.api.UtilitiesService 
utilities;
@ScriptService oracle.oats.scripting.modules.browser.api.BrowserService 
browser;
@ScriptService 
oracle.oats.scripting.modules.functionalTest.api.FunctionalTestService ft;
@ScriptService oracle.oats.scripting.modules.webdom.api.WebDomService web;

public void initialize() throws Exception {
    browser.launch();
}

/**
 * Add code to be executed each iteration for this virtual user.
 */
public void run() throws Exception {
    beginStep("[1] No Title (/hotelconfig.html)", 0);
    {
        web.window(2, "/web:window[@index='0' or @title='about:blank']")
                .navigate(
                        "URL");
        {
            think(0.093);
        }
    }
    endStep();
    beginStep("[2] Working... (/wia)", 0);
    {
        web.window(4, "/web:window[@index='0' or @title='about:blank']")
                .navigate(
                        "URL");
        web.window(
                5,
                "/web:window[@index='0']")
                .waitForPage(null);
        {
            think(6.198);
        }
        web.selectBox(
                6,
                "/web:window[@index='0']/web:document[@index='0']/web:form[@index='0']/web:select[(@id='office_id' or @name='office_id' or @index='10') and multiple mod 'False']")
                .selectOptionByText(
                        "Office");
        {
            think(2.636);
        }
        web.button(
                7,
                "/web:window[@index='0']/web:document[@index='0']/web:form[@index='0']/web:input_submit[@name='save' or @value='Save' or @index='0']")
                .click();
    }
    endStep();
    beginStep(
            "[3] Intranet - Property info - *Hotel Settings - *Hotel configuration (/hotelconfig.html)",
            0);
    {
        web.window(
                8,
                "/web:window[@index='0']")
                .waitForPage(null);
    }
    endStep();

}

public void finish() throws Exception {
}
}

我在网上和甲骨文的社区上都找不到解决方案。我还尝试运行OpenScript诊断工具,但没有成功。

有谁知道吗?

EN

回答 2

Stack Overflow用户

发布于 2018-02-02 15:55:12

Oracle Application Testing Suite (OATS)最好地支持读取csv数据表。您粘贴的代码只是记录您执行的代码,没有看到任何问题。屏幕截图显示错误消息,可能在创建csv时出错。

我可以建议使用外部excel阅读器,它内置在OATS本身的http://www.testinghive.com/category/oracle-application-testing-suite-tips/中。

代码语言:javascript
复制
//Define Sheet name to be read, and provide comma seperated to read multiple sheets
String sheetName = "Sheet1";
//Mention excel sheet path
String strFile= "C:\\Demo\\test.xls";

//Defined array list to add Sheets to read
List sheetList = new ArrayList();
sheetList.add(sheetName);
// Iports Sheet1
datatable.importSheets(strFile, sheetList, true, true);
//get rowcount
info("Total rows :"+datatable.getRowCount());
int rowcount=datatable.getRowCount();
//Loop to read all rows
for (int i=0;i<rowcount;i++)
{
//Set current row fromw here you need to start reading, in this case start from first row
datatable.setCurrentRow(sheetName, i);
String strCompany=(String) datatable.getValue(sheetName,i,"Company");
String strEmpFName=(String) datatable.getValue(sheetName,i,"FirstName");
String strEmpLName=(String) datatable.getValue(sheetName,i,"LastName");
String strEmpID=(String) datatable.getValue(sheetName,i,"EmpID");
String strLocation=(String) datatable.getValue(sheetName,i,"Location");

//prints first name and last name
System.out.println("First Name : "+strEmpFName+", Last Name : "+strEmpLName);

//Sets ACTIVE column in excel sheet to Y
String strActive="Y";
datatable.setValue(sheetName, i, datatable.getColumn(sheetName, datatable.getColumnIndex("Active")), strActive);

}

//Updates sheet with updated values ie ACTIVE column sets to Y
datatable.exportToExcel("C:\\Demo\\test1.xlsx");

}

public void finish() throws Exception {
}
}
票数 1
EN

Stack Overflow用户

发布于 2018-06-09 06:03:57

我发现使用数据库作为数据提供程序更容易。

通过添加具有必要变量的CSV文件,您将能够执行以下替换:

代码语言:javascript
复制
public void run() throws Exception {    
    getDatabank("databank").getNextDatabankRecord();
    String v_dataFilename = "{{db.databank.filename}}";
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45562577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档