Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在执行测试脚本时操作URL_Javascript_Testcafe - Fatal编程技术网

Javascript 如何在执行测试脚本时操作URL

Javascript 如何在执行测试脚本时操作URL,javascript,testcafe,Javascript,Testcafe,我尝试使用命令提示符执行TestCafe脚本。执行时,test cafe通过在URL旁边获取本地IP、端口号和会话ID来开始执行。我希望我的脚本直接在URL上执行,而不需要本地主机IP、端口和其他详细信息。当我在Test Cafe上执行脚本时,请参阅附件中的屏幕截图。 附件是在测试Cafe上执行的测试用例代码 import { Selector } from 'testcafe'; import { Crypto } from 'testcafe'; var faker = require('

我尝试使用命令提示符执行TestCafe脚本。执行时,test cafe通过在URL旁边获取本地IP、端口号和会话ID来开始执行。我希望我的脚本直接在URL上执行,而不需要本地主机IP、端口和其他详细信息。当我在Test Cafe上执行脚本时,请参阅附件中的屏幕截图。

附件是在测试Cafe上执行的测试用例代码

import { Selector } from 'testcafe';
import { Crypto } from 'testcafe';
var faker = require('faker');
function randomString(size) {  
    return crt
    .randomBytes(size)
    .toString('hex')
    .slice(0, size)
};

function numberGen(len) {       //Function to Generate random number; 
length of number = value specified in 'len'
 //  var genNum= Math.floor(Math.pow(10, len)*Math.random()).toString()
  var text = "";
    var charset = "0123456789";
    for( var i=0; i < len; i++ ) {
    text += charset.charAt(Math.floor(Math.random() * charset.length));}
    return text;
};
 const dataSet = require('./dataIUT.json');
const crt   = require('crypto')
var randomBankAccName = faker.random.alphaNumeric(6)+"Bank";
var AccountNumber = numberGen(9)
var AccountName = "AccName_"+faker.random.alphaNumeric(4)
fixture `CreateBankAccount`
.page `https://dev-assure-claims.dxc-rmcl.com/riskmasterux/#/login? 
clientId=3f28130450c00018`
.beforeEach(t => t.resizeWindow(1200, 1100));

dataSet.forEach(data => {    
test('CreateBankAccount', async t => {


//==================Login Code With JSON Starts================================       
    await t
    .maximizeWindow()
    .typeText(Selector('#username'), data.Username)
    .pressKey('tab')
    .typeText(Selector('#login-password'), data.Password)
    .pressKey('enter')
    .click(Selector('[ng-model="dsnSelected"]'))
    .click(Selector('[role="option"]').find('span').withText(data.DSN))
    .click(Selector('[ng-model="zoneSelected"]'))
    .click(Selector('[role="option"]').find('a').withText('Claims'))
    .click(Selector('#loginbox').find('button').withText('Continue'))
    .wait(1000)
//==================Login Code With JSON Ends================================    

//==================Code to Create Bank Account Starts ================================    

    .click(Selector('#menuBar').find('a').withText('Funds').nth(0))
    .click(Selector('#menu_FundsRoot').find('a').withText('Bank Account'))

    .switchToIframe(Selector('[id^="bankaccount"]'))
    .wait(1000)
    //var BankAccount = "BA_"+randomString(4).toUpperCase()
    //await t
    .click(Selector('#lookup_banklastname'))
    .typeText(Selector('#lookup_banklastname'), randomBankAccName).setTestSpeed(0.6).pressKey('tab')
    //.click(Selector('#accountnumber'))         
    .typeText(Selector('#accountnumber'), AccountNumber).setTestSpeed(0.6)
    .pressKey('tab')           
    .click(Selector('#accountname')).typeText(Selector('#accountname'), AccountName).setTestSpeed(0.6)
    .pressKey("tab")
    .click(Selector('#Save').find('i').withText('save'))
//==================Code to Create Bank Account Endss==================================

//========================Click to RHS Child's Add button Starts=========================
    const ele1 = Selector('[class="row main_menu right-panel-bg-hover"]').find('i').withText('add').with({ visibilityCheck: true }) // RHS Menu is available
    await t.expect(ele1.exists).ok('', { timeout: 20000 })
    .click(ele1)
//========================Click to RHS Child's Add button Ends=========================

//==========================Logout Code Starts==========================================
    .switchToMainWindow()
    .click(Selector('#morebtn').find('i').withText('more_vert'))
    

.click(Selector('#menu_othersMenu').find('a').withText('exit_to_appLogout'))
     .click(Selector('#btnRoll').find('i').withText('done'));
//===========================Logout Code Ends======================================== 
从“testcafe”导入{Selector};
从“testcafe”导入{Crypto};
var faker=要求(‘faker’);
函数随机字符串(大小){
返回式阴极射线管
.随机字节(大小)
.toString('hex')
.slice(0,大小)
};
函数numberGen(len){//生成随机数的函数;
数字的长度=在“len”中指定的值
//var genNum=Math.floor(Math.pow(10,len)*Math.random()).toString()
var text=“”;
var charset=“0123456789”;
对于(变量i=0;it.resizeWindow(12001100));
dataSet.forEach(数据=>{
测试('CreateBankAccount',异步t=>{
//==============================================================================================
等待
.maximeWindow()
.typeText(选择器(“#用户名”),data.username)
.按键('tab')
.typeText(选择器(“#登录密码”),data.password)
.按键('输入')
。单击(选择器('[ng model=“dsselected”]'))
。单击(选择器('[role=“option”]')。查找('span')。使用文本(data.DSN))
。单击(选择器('[ng model=“zoneSelected”]'))
。单击(选择器('[role=“option”]')。查找('a')。使用文本('Claims'))
。单击(选择器(“#登录框”)。查找('button')。使用文本('Continue'))
.等等(1000)
//===========================================================================================
//==============================================================================================
。单击(选择器(“#菜单栏”)。查找('a')。使用文本('Funds')。第n(0))
。单击(选择器(“#菜单"基金启动”)。查找('a')。使用文本('银行帐户'))
.switchToIframe(选择器('[id^=“bankaccount”]'))
.等等(1000)
//var BankAccount=“BA_389;”+randomString(4).toUpperCase()
//等待
。单击(选择器(“#查找_banklastname”))
.typeText(选择器(“#lookup_banklastname”),randomBankAccName)。setTestSpeed(0.6)。按键('tab'))
//。单击(选择器(“#帐户编号”))
.typeText(选择器('#accountnumber'),accountnumber).setTestSpeed(0.6)
.按键('tab')
。单击(选择器('#accountname'))。键入文本(选择器('#accountname'),accountname)。设置速度(0.6)
。按键(“制表符”)
。单击(选择器(“#保存”)。查找('i')。使用文本('Save'))
//======================创建银行帐户结束的代码==================================
//=====================================单击以开始RHS孩子的添加按钮=========================
const ele1=选择器('[class=“row main_menu right panel bg hover”]')。查找('i')。使用文本('add')。使用({visibilityCheck:true})//RHS菜单可用
wait t t.expect(ele1.exists).ok(“”,{timeout:20000})
。单击(ele1)
//==================================单击以添加RHS孩子的按钮=========================
//==============================================注销代码开始==========================================
.switchToMainWindow()
。单击(选择器(“#morebtn”)。查找('i')。使用文本('more#vert'))
。单击(选择器(“#菜单_其他菜单”)。查找('a')。使用文本('exit_to_appLogout'))
.单击(选择器('#btnRoll')。查找('i')。使用文本('done'));
//==========================================================================================================

})),

在本地主机上“运行”测试会导致什么问题?你到底想解决什么问题


您看到的是TestCafe与其他设备的通信查看文档,不可能让TestCafe与非您当前机器的设备通信,因此,我认为您不可能实现任何目标。

您可以提供测试代码吗?我想通过burp tool上的test cafe脚本扫描请求,以实现安全测试您可以使用Testcafe的截获来记录所有HTTP请求:。我相信,你可以用它的输出让它们打嗝。我没有打嗝,所以我不太确定。