Our objective is to get the value of url
and sitelab
element from the CLI. Then append it in the fixture.page()
.
Run command: testcafe edge testfile.js --url="https://www.google.com" --sitelab="grp"
//testfile.js
const siteURL1 = sitelabURL();
fixture('Header -POC').page(siteURL1());
//From below code trying to generate URL from a command line
export const url1 = () => {
let URL = 'https://www.google.com';
const URL_KEY = '--url';
process.argv.forEach((val) => {
const keyValuePair = val.split('=');
if (URL_KEY === keyValuePair[0]) {
URL = keyValuePair[1];
}
});
return URL;
};
export async function sitelab() {
let SITELAB = 'sitelab:T1';
const SITELAB_KEY = '--sitelab';
process.argv.forEach((val) => {
const keyValuePair = val.split('=');
if (SITELAB_KEY === keyValuePair[0]) {
SITELAB = keyValuePair[1];
}
});
return SITELAB;
};
export const sitelabURL = async () => {
// sitelab();
var localURL = url1();
var sitelab1 = await sitelab();
var tld = localURL.indexOf('.com') > 0 ? 'com' : 'co.jp';
if(sitelab1=true){
var sitelabURL = 'http://www.google.'+tld+'/cookie.html?url='+localURL+'&rc='+sitelab1;
return sitelabURL.toString();
}
else {
return localURL.toString();
}
}
Actual Result:
TypeError: sitelabURL1 is not a function
Expected Result:
Value should be successfully appended in the fixture and the page should be loaded
Note: I tried with fixture('Header -POC').page(siteURL1);
as well. Here the result is The page URL is expected to be a string, but it was object.
Aucun commentaire:
Enregistrer un commentaire