我是imacros代码和javacript的新手,实际上我没有这方面的经验,所以我想问一些东西,所以在imacros中我使用javascript languange,这里有一些代码:
var filesource = imns.Dialogs.browseForFileOpen("Enter file location");
if (filesource)
fs = filesource.path;
var y = prompt("start","2");
var z = prompt("end","20");
y=parseInt(y);
z=parseInt(z);
posting="CODE:"+"\n"
posting+="SET !ERRORIGNORE YES"+"\n"
posting+="SET !DATASOURCE {{filesource}}"+"\n"
posting+="SET !DATASOURCE_LINE {{LOOP}}"+"\n"
posting+="SET !WAITPAGECOMPLETE YES"+"\n"
posting+="URL GOTO=https://www.examples.com"+"\n"
posting+="TAG POS=1 TYPE=SPAN ATTR=CLASS:selectBox-arrow"+"\n"
posting+="TAG POS=1 TYPE=SELECT FORM=NAME:frm_add_product ATTR=NAME:p_dep_1 CONTENT=%0"+"\n"
posting+="WAIT SECONDS=2"+"\n"
posting+="TAG POS=1 TYPE=SELECT FORM=NAME:frm_add_product ATTR=NAME:p_menu_id CONTENT=${{!COL23}}"+"\n"
posting+="TAG POS=1 TYPE=INPUT:FILE FORM=ID:frm-add-product ATTR=accept:image/jpeg,image/png CONTENT={{!COL11}}"+"\n"
posting+="TAG POS=1 TYPE=INPUT:FILE FORM=ID:frm-add-product ATTR=accept:image/jpeg,image/png CONTENT={{!COL12}}"+"\n"
posting+="TAG POS=1 TYPE=INPUT:FILE FORM=ID:frm-add-product ATTR=accept:image/jpeg,image/png CONTENT={{!COL13}}"+"\n"
posting+="TAG POS=1 TYPE=INPUT:FILE FORM=ID:frm-add-product ATTR=accept:image/jpeg,image/png CONTENT={{!COL14}}"+"\n"
posting+="TAG POS=1 TYPE=INPUT:FILE FORM=ID:frm-add-product ATTR=accept:image/jpeg,image/png CONTENT={{!COL15}}"+"\n"
posting+="TAG POS=1 TYPE=INPUT:TEXT FORM=ID:frm-add-product ATTR=ID:p-name CONTENT={{!COL1}}"+"\n"
posting+="TAG POS=1 TYPE=TEXTAREA FORM=ID:frm-add-product ATTR=ID:p-description CONTENT={{!COL6}}"+"\n"
posting+="TAG POS=1 TYPE=INPUT:TEXT FORM=ID:frm-add-product ATTR=ID:p-price CONTENT={{!COL3}}"+"\n"
posting+="TAG POS=1 TYPE=INPUT:TEXT FORM=ID:frm-add-product ATTR=ID:p-weight CONTENT={{!COL4}}"+"\n"
posting+="TAG POS=1 TYPE=INPUT:RADIO FORM=ID:frm-add-product ATTR=ID:p-condition-new"+"\n"
posting+="TAG POS=1 TYPE=SPAN ATTR=CLASS:selectBox-arrow"+"\n"
posting+="TAG POS=1 TYPE=SELECT FORM=NAME:frm_add_product ATTR=NAME:p_dep_1 CONTENT=${{!COL8}}"+"\n"
posting+="WAIT SECONDS=2"+"\n"
posting+="TAG POS=2 TYPE=SPAN ATTR=CLASS:selectBox-arrow"+"\n"
posting+="TAG POS=1 TYPE=SELECT FORM=NAME:frm_add_product ATTR=NAME:p_dep_2 CONTENT=${{!COL9}}"+"\n"
posting+="WAIT SECONDS=2"+"\n"
posting+="TAG POS=3 TYPE=SPAN ATTR=CLASS:selectBox-arrow"+"\n"
posting+="TAG POS=1 TYPE=SELECT FORM=NAME:frm_add_product ATTR=NAME:p_dep_3 CONTENT=${{!COL10}}"+"\n"
posting+="WAIT SECONDS=2"+"\n"
posting+="TAG POS=1 TYPE=SELECT FORM=NAME:frm_add_product ATTR=NAME:p_menu_id CONTENT=$**<SP>Tambah<SP>Etalase"+"\n"
posting+="TAG POS=1 TYPE=INPUT:TEXT FORM=ID:frm-add-product ATTR=ID:p-menu-name CONTENT={{!COL16}}"+"\n"
posting+="TAG POS=1 TYPE=SELECT FORM=NAME:frm_add_product ATTR=NAME:p_menu_id CONTENT=${{!COL16}}"+"\n"
posting+="TAG POS=1 TYPE=a ATTR=ID:invenagebox"+"\n"
posting+="TAG POS=1 TYPE=INPUT:TEXT FORM=ID:frm-add-product ATTR=ID:invenage-value CONTENT={{!COL5}}"+"\n"
posting+="WAIT SECONDS=2"+"\n"
posting+="TAG POS=1 TYPE=BUTTON FORM=ID:frm-add-product ATTR=ID:s-save-prod"+"\n"
posting+="WAIT SECONDS=10"+"\n"
posting+="TAG POS=1 TYPE=ul ATTR=class:square<sp>break-word extract=txt"+"\n"
posting+="set nama EVAL(\"'{{!EXTRACT}}'.replace('Anda telah berhasil memasukkan produk ','')\")"+"\n"
for (i=y;i<=z;i++){
iimSet("cat1",cat1);
iimSet("cat2",cat2);
iimSet("cat3",cat3);
iimSet("ETA",eta);
iimSet("filesource",fs);
iimSet("LOOP",i);
iimPlay(posting);
}
所以关键是我想用随机方向和随机像素滚动页面。我尝试过使用URL GOTO=javascript:window.scrollBy(0,2000) , but it didnt work.
注意:我使用excel逗号分隔值(csv)作为我的代码的源,我想在excel表的每一行添加一些随机数,但它没有工作导致URL GOTO=javascript:window.scrollBy(0,2000)
这不起作用。< / p>
任何帮助将不胜感激 请原谅我的英语和我的语法纳粹
答案 0 :(得分:1)
而不是
URL GOTO=javascript:window.scrollBy(0,randomNumber)
你可以试试这段代码:
' your value here '
SET maxScroll 50
SET keys EVAL("var k = []; for (i = 0; i <= 1 + Math.floor(Math.random()*{{maxScroll}}); i++) k.push(40); k;")
EVENTS TYPE=KEYPRESS SELECTOR=* KEYS="[{{keys}}]"
因此,您不需要在Excel工作表的每一行添加一些随机数。
用JavaScript包装:
// ...
posting += 'SET maxScroll 50' + "\n";
posting += 'SET keys EVAL("var k = []; for (i = 0; i <= 1 + Math.floor(Math.random()*{{maxScroll}}); i++) k.push(40); k;")' + "\n";
posting += 'EVENTS TYPE=KEYPRESS SELECTOR=* KEYS="[{{keys}}]"' + "\n";
// ...